[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28893 - libmicrohttpd/src/examples
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28893 - libmicrohttpd/src/examples |
Date: |
Thu, 29 Aug 2013 00:43:31 +0200 |
Author: andreyu
Date: 2013-08-29 00:43:31 +0200 (Thu, 29 Aug 2013)
New Revision: 28893
Modified:
libmicrohttpd/src/examples/mhd2spdy.c
libmicrohttpd/src/examples/mhd2spdy_http.c
libmicrohttpd/src/examples/mhd2spdy_http.h
libmicrohttpd/src/examples/mhd2spdy_spdy.c
libmicrohttpd/src/examples/mhd2spdy_structures.h
Log:
mhd2spdy: changes to use MHDs request completed callback
Modified: libmicrohttpd/src/examples/mhd2spdy.c
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy.c 2013-08-28 18:42:55 UTC (rev
28892)
+++ libmicrohttpd/src/examples/mhd2spdy.c 2013-08-28 22:43:31 UTC (rev
28893)
@@ -114,7 +114,8 @@
MHD_SUPPRESS_DATE_NO_CLOCK,
glob_opt.listen_port,
NULL, NULL, &http_cb_request, NULL,
- MHD_OPTION_URI_LOG_CALLBACK, &http_log_cb, NULL,
+ MHD_OPTION_URI_LOG_CALLBACK, &http_cb_log, NULL,
+ MHD_OPTION_NOTIFY_COMPLETED, &http_cb_request_completed, NULL,
MHD_OPTION_END);
if(NULL==daemon)
DIE("MHD_start_daemon failed");
@@ -175,7 +176,7 @@
PRINT_INFO2("select error: %i", errno);
break;
case 0:
- break;
+ //break;
default:
PRINT_INFO("run");
//MHD_run_from_select(daemon,&rs, &ws, &es); //not closing FDs at some
time in past
Modified: libmicrohttpd/src/examples/mhd2spdy_http.c
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_http.c 2013-08-28 18:42:55 UTC (rev
28892)
+++ libmicrohttpd/src/examples/mhd2spdy_http.c 2013-08-28 22:43:31 UTC (rev
28893)
@@ -27,7 +27,7 @@
void *
-http_log_cb(void * cls,
+http_cb_log(void * cls,
const char * uri)
{
(void)cls;
@@ -45,7 +45,7 @@
static int
-http_iterate_cb(void *cls,
+http_cb_iterate(void *cls,
enum MHD_ValueKind kind,
const char *name,
const char *value)
@@ -76,7 +76,7 @@
static ssize_t
-http_response_callback (void *cls,
+http_cb_response (void *cls,
uint64_t pos,
char *buffer,
size_t max)
@@ -89,9 +89,9 @@
const union MHD_ConnectionInfo *info;
int val = 1;
- PRINT_INFO2("http_response_callback for %s", proxy->url);
+ PRINT_INFO2("http_cb_response for %s", proxy->url);
- if(proxy->error)
+ if(proxy->spdy_error)
return MHD_CONTENT_READER_END_WITH_ERROR;
if(0 == proxy->http_body_size &&( proxy->done || !proxy->spdy_active)){
@@ -145,18 +145,15 @@
static void
-http_response_done_callback(void *cls)
+http_cb_response_done(void *cls)
{
- struct Proxy *proxy = (struct Proxy *)cls;
- PRINT_INFO2("http_response_done_callback for %s", proxy->url);
+ //TODO
+ /*struct Proxy *proxy = (struct Proxy *)cls;
- if(proxy->spdy_active)
- proxy->http_active = false;
- else
- free_proxy(proxy);
+ PRINT_INFO2("http_cb_response_done for %s", proxy->url);
+ */
- --glob_opt.responses_pending;
}
int
@@ -291,7 +288,7 @@
spdy_headers.cnt = 10;
MHD_get_connection_values (connection,
MHD_HEADER_KIND,
- &http_iterate_cb,
+ &http_cb_iterate,
&spdy_headers);
spdy_headers.nv[spdy_headers.cnt] = NULL;
@@ -309,9 +306,9 @@
proxy->http_response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN,
4096,
- &http_response_callback,
+ &http_cb_response,
proxy,
- &http_response_done_callback);
+ &http_cb_response_done);
if (proxy->http_response == NULL)
DIE("no response");
@@ -371,3 +368,33 @@
MHD_destroy_response (proxy->http_response);
}
+
+void
+http_cb_request_completed (void *cls,
+ struct MHD_Connection *connection,
+ void **con_cls,
+ enum MHD_RequestTerminationCode toe)
+{
+ struct HTTP_URI *http_uri = (struct HTTP_URI *)*con_cls;
+ if(NULL == http_uri) return;
+ struct Proxy *proxy = (struct Proxy *)http_uri->proxy;
+
+ PRINT_INFO2("http_cb_request_completed %i for %s",toe, http_uri->uri);
+
+ if(proxy->spdy_active)
+ {
+ proxy->http_active = false;
+ if(MHD_REQUEST_TERMINATED_COMPLETED_OK != toe)
+ {
+ proxy->http_error = true;
+ assert(proxy->stream_id > 0);
+ //send RST_STREAM_STATUS_CANCEL
+ PRINT_INFO("send rst_stream" );
+ spdylay_submit_rst_stream(proxy->spdy_connection->session,
proxy->stream_id, 5);
+ }
+ }
+ else
+ free_proxy(proxy);
+
+ --glob_opt.responses_pending;
+}
Modified: libmicrohttpd/src/examples/mhd2spdy_http.h
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_http.h 2013-08-28 18:42:55 UTC (rev
28892)
+++ libmicrohttpd/src/examples/mhd2spdy_http.h 2013-08-28 22:43:31 UTC (rev
28893)
@@ -38,11 +38,17 @@
void **ptr);
-void * http_log_cb(void * cls, const char * uri);
+void * http_cb_log(void * cls, const char * uri);
void
http_create_response(struct Proxy* proxy, char **nv);
+void
+http_cb_request_completed (void *cls,
+ struct MHD_Connection *connection,
+ void **con_cls,
+ enum MHD_RequestTerminationCode toe);
+
#endif
Modified: libmicrohttpd/src/examples/mhd2spdy_spdy.c
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_spdy.c 2013-08-28 18:42:55 UTC (rev
28892)
+++ libmicrohttpd/src/examples/mhd2spdy_spdy.c 2013-08-28 22:43:31 UTC (rev
28893)
@@ -334,7 +334,7 @@
break;
case SPDYLAY_RST_STREAM:
PRINT_INFO2("received reset stream for %s", proxy->url);
- proxy->error = true;
+ proxy->spdy_error = true;
break;
case SPDYLAY_HEADERS:
PRINT_INFO2("received headers for %s", proxy->url);
@@ -398,7 +398,13 @@
struct Proxy *proxy;
proxy = spdylay_session_get_stream_user_data(session, stream_id);
-
+
+ if(NULL == proxy)
+ {
+ PRINT_INFO("proxy in spdy_cb_on_data_chunk_recv is NULL)");
+ return;
+ }
+
if(!copy_buffer(data, len, &proxy->http_body, &proxy->http_body_size))
{
//TODO handle it better?
@@ -1076,9 +1082,9 @@
else
{
PRINT_INFO("not called");
- PRINT_INFO2("connection->want_io %i",connections[i]->want_io);
- PRINT_INFO2("read
%i",spdylay_session_want_read(connections[i]->session));
- PRINT_INFO2("write
%i",spdylay_session_want_write(connections[i]->session));
+ //PRINT_INFO2("connection->want_io %i",connections[i]->want_io);
+ //PRINT_INFO2("read
%i",spdylay_session_want_read(connections[i]->session));
+ //PRINT_INFO2("write
%i",spdylay_session_want_write(connections[i]->session));
//raise(SIGINT);
}
}
Modified: libmicrohttpd/src/examples/mhd2spdy_structures.h
===================================================================
--- libmicrohttpd/src/examples/mhd2spdy_structures.h 2013-08-28 18:42:55 UTC
(rev 28892)
+++ libmicrohttpd/src/examples/mhd2spdy_structures.h 2013-08-28 22:43:31 UTC
(rev 28893)
@@ -120,7 +120,8 @@
int id;
int32_t stream_id;
bool done;
- bool error;
+ bool http_error;
+ bool spdy_error;
bool http_active;
bool spdy_active;
bool receiving_done;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28893 - libmicrohttpd/src/examples,
gnunet <=