char host[256];
/* The associated daemon list entry */
- struct MhdHttpList *daemon;
+ struct MhdHttpList *mhd;
};
/* The non SSL httpd daemon handle */
static struct MHD_Daemon *httpd;
-/* The http task ID */
-static GNUNET_SCHEDULER_TaskIdentifier httpd_task;
-
/* The cURL multi handle */
static CURLM *curl_multi;
/* Handle to the regex for dotplus (.+) replacement in HTML */
static regex_t re_dotplus;
+
/**
* Checks if name is in tld
*
run_mhd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct MhdHttpList *hd;
+ struct MhdHttpList *hd = cls;
- for (hd=mhd_httpd_head; hd != NULL; hd = hd->next)
+ //for (hd=mhd_httpd_head; hd != NULL; hd = hd->next)
MHD_run (hd->daemon);
}
//GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
// "cURL chunk:\n%s\n", (char*)ctask->buffer);
- run_mhd (NULL, NULL);
+ //run_mhd (NULL, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
return total;
}
}
-
-
-
/**
* Shorten result callback
*
ctask->pp_finished = GNUNET_YES;
- GNUNET_SCHEDULER_add_now (&run_mhd, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
}
ctask->download_in_progress = GNUNET_NO;
curl_multi_remove_handle (curl_multi, ctask->curl);
curl_easy_cleanup (ctask->curl);
- GNUNET_SCHEDULER_add_now (&run_mhd, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
return MHD_CONTENT_READER_END_OF_STREAM;
}
ctask->download_in_progress = GNUNET_NO;
curl_multi_remove_handle (curl_multi, ctask->curl);
curl_easy_cleanup (ctask->curl);
- GNUNET_SCHEDULER_add_now (&run_mhd, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
return MHD_CONTENT_READER_END_WITH_ERROR;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Skipping next %d bytes in buffer\n", m[0].rm_eo);
- GNUNET_SCHEDULER_add_now (&run_mhd, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
if ( strlen (ctask->pp_buf) <= max )
{
ctask->buf_status = BUF_WAIT_FOR_CURL;
ctask->buffer_ptr = ctask->buffer;
curl_easy_pause (ctask->curl, CURLPAUSE_CONT);
- GNUNET_SCHEDULER_add_now (&run_mhd, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
}
}
- GNUNET_SCHEDULER_add_now (&run_mhd, NULL);
+ GNUNET_SCHEDULER_add_now (&run_mhd, ctask->mhd);
return copied;
}
void **con_cls)
{
static int dummy;
+ struct MhdHttpList* hd = cls;
const char* page = "<html><head><title>gnoxy</title>"\
"</head><body>cURL fail</body></html>";
struct MHD_Response *response;
/* Do cURL */
ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask));
+ ctask->mhd = hd;
ctask->curl = curl_easy_init();
if (curl_multi == NULL)
GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1);
- if (httpd_task != GNUNET_SCHEDULER_NO_TASK)
+ if (hd->httpd_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (hd->httpd_task);
hd->httpd_task =
GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
strcpy (hd->domain, domain);
hd->daemon = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL, http_port++,
NULL, NULL,
- &create_response, NULL,
+ &create_response, hd,
MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 128,
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
MHD_OPTION_NOTIFY_COMPLETED,
{
tmp_hd = hd->next;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stopping daemon\n");
+
if (GNUNET_SCHEDULER_NO_TASK != hd->httpd_task)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Stopping select task %d\n",
+ hd->httpd_task);
GNUNET_SCHEDULER_cancel (hd->httpd_task);
hd->httpd_task = GNUNET_SCHEDULER_NO_TASK;
}
GNUNET_free (hd);
}
+
+ GNUNET_GNS_disconnect (gns_handle);
}
strcpy (hd->domain, "");
httpd = MHD_start_daemon (MHD_USE_DEBUG, http_port++,
NULL, NULL,
- &create_response, NULL,
+ &create_response, hd,
MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 128,
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
MHD_OPTION_NOTIFY_COMPLETED,