- CURLM *mhnd;
- CURLMsg *msg;
- int nmsg;
-
- global.nrun = nnrun;
- mhnd = global.mhnd;
-
- syslog(LOG_DEBUG, "CURLEV: gotstatus(): about to call curl_multi_info_read\n");
- while ((msg = curl_multi_info_read(mhnd, &nmsg))) {
- syslog(LOG_ERR, "EVCURL: got curl multi_info message msg=%d\n", msg->msg);
- if (CURLMSG_DONE == msg->msg) {
- CURL *chnd;
- char *chandle;
- CURLcode sta;
- CURLMcode msta;
- AsyncIO *IO;
-
- chandle = NULL;;
- chnd = msg->easy_handle;
- sta = curl_easy_getinfo(chnd, CURLINFO_PRIVATE, &chandle);
- syslog(LOG_ERR, "EVCURL: request complete\n");
- if (sta)
- syslog(LOG_ERR, "EVCURL: error asking curl for private cookie of curl handle: %s\n", curl_easy_strerror(sta));
- IO = (AsyncIO *)chandle;
-
- ev_io_stop(event_base, &IO->recv_event);
- ev_io_stop(event_base, &IO->send_event);
-
- sta = msg->data.result;
- if (sta) {
- syslog(LOG_ERR, "EVCURL: error description: %s\n", IO->HttpReq.errdesc);
- syslog(LOG_ERR, "EVCURL: error performing request: %s\n", curl_easy_strerror(sta));
- }
- sta = curl_easy_getinfo(chnd, CURLINFO_RESPONSE_CODE, &IO->HttpReq.httpcode);
- if (sta)
- syslog(LOG_ERR, "EVCURL: error asking curl for response code from request: %s\n", curl_easy_strerror(sta));
- syslog(LOG_ERR, "EVCURL: http response code was %ld\n", (long)IO->HttpReq.httpcode);
-
-
- curl_slist_free_all(IO->HttpReq.headers);
- msta = curl_multi_remove_handle(mhnd, chnd);
- if (msta)
- syslog(LOG_ERR, "EVCURL: warning problem detaching completed handle from curl multi: %s\n", curl_multi_strerror(msta));
-
- curl_easy_cleanup(IO->HttpReq.chnd);
- IO->HttpReq.chnd = NULL;
-
- IO->HttpReq.attached = 0;
- IO->SendDone(IO);
-
- FreeStrBuf(&IO->HttpReq.ReplyData);
- FreeURL(&IO->ConnectMe);
- RemoveContext(IO->CitContext);
- IO->Terminate(IO);
- }
- }
+ CURLMsg *msg;
+ int nmsg;
+
+ global.nrun = nnrun;
+
+ syslog(LOG_DEBUG,
+ "CURLEV: gotstatus(): about to call curl_multi_info_read\n");
+ while ((msg = curl_multi_info_read(global.mhnd, &nmsg))) {
+ syslog(LOG_ERR,
+ "EVCURL: got curl multi_info message msg=%d\n",
+ msg->msg);
+
+ if (CURLMSG_DONE == msg->msg) {
+ CURL *chnd;
+ char *chandle;
+ CURLcode sta;
+ CURLMcode msta;
+ AsyncIO*IO;
+
+ chandle = NULL;;
+ chnd = msg->easy_handle;
+ sta = curl_easy_getinfo(chnd,
+ CURLINFO_PRIVATE,
+ &chandle);
+ syslog(LOG_ERR, "EVCURL: request complete\n");
+ if (sta)
+ syslog(LOG_ERR,
+ "EVCURL: error asking curl for private"
+ " cookie of curl handle: %s\n",
+ curl_easy_strerror(sta));
+ IO = (AsyncIO *)chandle;
+
+ IO->Now = ev_now(event_base);
+
+ ev_io_stop(event_base, &IO->recv_event);
+ ev_io_stop(event_base, &IO->send_event);
+
+ sta = msg->data.result;
+ if (sta) {
+ EV_syslog(LOG_ERR,
+ "EVCURL: error description: %s\n",
+ IO->HttpReq.errdesc);
+ EV_syslog(LOG_ERR,
+ "EVCURL: error performing request: %s\n",
+ curl_easy_strerror(sta));
+ }
+ sta = curl_easy_getinfo(chnd,
+ CURLINFO_RESPONSE_CODE,
+ &IO->HttpReq.httpcode);
+ if (sta)
+ EV_syslog(LOG_ERR,
+ "EVCURL: error asking curl for "
+ "response code from request: %s\n",
+ curl_easy_strerror(sta));
+ EV_syslog(LOG_ERR,
+ "EVCURL: http response code was %ld\n",
+ (long)IO->HttpReq.httpcode);
+
+
+ curl_slist_free_all(IO->HttpReq.headers);
+ msta = curl_multi_remove_handle(global.mhnd, chnd);
+ if (msta)
+ EV_syslog(LOG_ERR,
+ "EVCURL: warning problem detaching "
+ "completed handle from curl multi: "
+ "%s\n",
+ curl_multi_strerror(msta));
+
+ ev_cleanup_stop(event_base, &IO->abort_by_shutdown);
+
+ IO->HttpReq.attached = 0;
+ switch(IO->SendDone(IO))
+ {
+ case eDBQuery:
+ curl_easy_cleanup(IO->HttpReq.chnd);
+ IO->HttpReq.chnd = NULL;
+ break;
+ case eSendDNSQuery:
+ case eReadDNSReply:
+ case eConnect:
+ case eSendReply:
+ case eSendMore:
+ case eSendFile:
+ case eReadMessage:
+ case eReadMore:
+ case eReadPayload:
+ case eReadFile:
+ curl_easy_cleanup(IO->HttpReq.chnd);
+ IO->HttpReq.chnd = NULL;
+ break;
+ case eTerminateConnection:
+ case eAbort:
+ curl_easy_cleanup(IO->HttpReq.chnd);
+ IO->HttpReq.chnd = NULL;
+ FreeStrBuf(&IO->HttpReq.ReplyData);
+ FreeURL(&IO->ConnectMe);
+ RemoveContext(IO->CitContext);
+ IO->Terminate(IO);
+ }
+ }
+ }