diff -Nur asterisk-1.8.20.1.orig//apps/app_queue.c asterisk-1.8.20.1.new//apps/app_queue.c --- asterisk-1.8.20.1.orig//apps/app_queue.c 2013-01-09 21:30:25.000000000 +0100 +++ asterisk-1.8.20.1.new//apps/app_queue.c 2013-02-21 18:57:56.000000000 +0100 @@ -1526,6 +1526,18 @@ if (!strcasecmp(interface, sc->dev)) { found = 1; + /* We could have gotten here without the queue + * knowing this call was actually transfered. If an attended was attempted, but + * before the called party answered the call is disconnected, the TRANSFER is + * triggered too late. Correct for this fact in a way that if the status was in + * use, set the lastcall time to now, so the wrapuptime is honored. + * Possible, more checking must be done, since technically the agent is done with + * the call at this point, and not when the called party answers (the ringing time + * is wrongly reported in the queue_log now!!!). */ + if (m->status == AST_DEVICE_INUSE) { + ast_debug(3, "Hangup for member device %s, which was %s, so set lastcall time to now\n", sc->dev, ast_devstate2str(AST_DEVICE_INUSE)); + time(&m->lastcall); + } update_status(q, m, sc->state); ao2_ref(m, -1); break;