On 25 October 2014 17:52, Amit Kapila Wrote, >*************** >*** 358,363 **** handle_sigint(SIGNAL_ARGS) >--- 358,364 ---- > > /* Send QueryCancel if we are processing a database query */ > if (cancelConn != NULL) > { >+ inAbort = true; > if (PQcancel(cancelConn, errbuf, sizeof(errbuf))) > fprintf(stderr, _("Cancel request sent\n")); > else > >Do we need to set inAbort flag incase PQcancel is successful? >Basically if PQCancel fails due to any reason, I think behaviour >can be undefined as the executing thread can assume that cancel is >done. > >*** 391,396 **** consoleHandler(DWORD dwCtrlType) >--- 392,399 ---- > EnterCriticalSection >(&cancelConnLock); > if (cancelConn != NULL) > { >+ inAbort = >true; >+
In “handle_sigint” function if we are going to cancel the query that time I am setting the flag inAbort (even when it is success), so that in “select_loop” function If select(maxFd + 1, workerset, NULL, NULL, &tv); come out, we can know whether it came out because of cancel query and handle it accordingly. i = select(maxFd + 1, workerset, NULL, NULL, NULL); if (in_abort()) //loop break because of cancel query, so return fail… { return -1; } if (i < 0 && errno == EINTR) continue; Regards, Dilip Kumar