- 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);
-
- 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);
-/// syslog(LOG_ERR, "EVCURL: disconnecting [%s]\nn", ChrPtr(IO->ConnectMe->URL));
- 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));
-/// syslog(LOG_ERR, "EVCURL: disconnection done [%s]\nn", ChrPtr(IO->ConnectMe->URL));
-
- IO->HttpReq.attached = 0;
- IO->SendDone(IO);
-//// syslog(LOG_ERR, "EVCURL: done with [%s]\nn", ChrPtr(IO->ConnectMe->URL));
-
-
- curl_easy_cleanup(IO->HttpReq.chnd);
- curl_slist_free_all(IO->HttpReq.headers);
-/*
- FreeStrBuf(&IO->HttpReq.ReplyData);
- FreeURL(&IO->ConnectMe);
- RemoveContext(IO->CitContext);
- IO->Terminate(IO);
-*/
- }
- }
+ CURLMsg *msg;
+ int nmsg;
+
+ global.nrun = nnrun;
+
+ CURLM_syslog(LOG_DEBUG,
+ "gotstatus(): about to call curl_multi_info_read\n");
+ while ((msg = curl_multi_info_read(global.mhnd, &nmsg))) {
+ CURL_syslog(LOG_DEBUG,
+ "got curl multi_info message msg=%d\n",
+ msg->msg);
+
+ if (CURLMSG_DONE == msg->msg) {
+ CURL *chnd;
+ char *chandle = NULL;
+ CURLcode sta;
+ CURLMcode msta;
+ AsyncIO*IO;
+
+ chandle = NULL;;
+ chnd = msg->easy_handle;
+ sta = curl_easy_getinfo(chnd,
+ CURLINFO_PRIVATE,
+ &chandle);
+ if (sta) {
+ EVCURL_syslog(LOG_ERR,
+ "error asking curl for private"
+ " cookie of curl handle: %s\n",
+ curl_easy_strerror(sta));
+ continue;
+ }
+ IO = (AsyncIO *)chandle;
+ if (IO->ID == 0) {
+ EVCURL_syslog(LOG_ERR,
+ "Error, invalid IO context %p\n",
+ IO);
+ continue;
+ }
+
+ EVCURLM_syslog(LOG_DEBUG, "request complete\n");
+
+ 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) {
+ EVCURL_syslog(LOG_ERR,
+ "error description: %s\n",
+ IO->HttpReq.errdesc);
+ EVCURL_syslog(LOG_ERR,
+ "error performing request: %s\n",
+ curl_easy_strerror(sta));
+ }
+ sta = curl_easy_getinfo(chnd,
+ CURLINFO_RESPONSE_CODE,
+ &IO->HttpReq.httpcode);
+ if (sta)
+ EVCURL_syslog(LOG_ERR,
+ "error asking curl for "
+ "response code from request: %s\n",
+ curl_easy_strerror(sta));
+ EVCURL_syslog(LOG_DEBUG,
+ "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)
+ EVCURL_syslog(LOG_ERR,
+ "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);
+ }
+ }
+ }