From: Matthias Wachs Date: Wed, 23 Jun 2010 15:36:02 +0000 (+0000) Subject: (no commit message) X-Git-Tag: initial-import-from-subversion-38251~21249 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4377ade158e5b6d0e60c3ad1eae2ae74d892d973;p=oweals%2Fgnunet.git --- diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 8b565517e..0136ae0ad 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -200,11 +200,6 @@ struct Session */ int is_client; - /** - * Is the connection active (GNUNET_YES) or terminated (GNUNET_NO)? - */ - int is_active; - /** * At what time did we reset last_received last? */ @@ -347,7 +342,6 @@ static struct Session * create_session (void * cls, char * addr_in, size_t addrl ses->plugin = plugin; memcpy(&ses->partner, peer, sizeof (struct GNUNET_PeerIdentity)); GNUNET_CRYPTO_hash_to_enc(&ses->partner.hashPubKey,&(ses->hash)); - ses->is_active = GNUNET_NO; ses->pending_inbound_msg.bytes_recv = 0; ses->msgtok = NULL; return ses; @@ -363,10 +357,10 @@ static void requestCompletedCallback (void *cls, struct MHD_Connection * connect cs = *httpSessionCache; if (cs == NULL) return; - /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&cs->partner));*/ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&cs->partner)); /* session set to inactive */ - cs->is_active = GNUNET_NO; cs->is_put_in_progress = GNUNET_NO; + cs->is_bad_request = GNUNET_NO; } @@ -515,7 +509,7 @@ accessHandlerCallback (void *cls, cs = *httpSessionCache; } /* Is it a PUT or a GET request */ - if ( 0 == strcmp (MHD_HTTP_METHOD_PUT, method) ) + if (0 == strcmp (MHD_HTTP_METHOD_PUT, method)) { /* New */ if ((*upload_data_size == 0) && (cs->is_put_in_progress == GNUNET_NO)) @@ -530,7 +524,6 @@ accessHandlerCallback (void *cls, /* not yet ready */ cs->is_put_in_progress = GNUNET_YES; cs->is_bad_request = GNUNET_NO; - cs->is_active = GNUNET_YES; return MHD_YES; } @@ -576,12 +569,8 @@ accessHandlerCallback (void *cls, { send_error_to_client = GNUNET_YES; if (cs->pending_inbound_msg.bytes_recv >= sizeof (struct GNUNET_MessageHeader)) - { - //res = GNUNET_SERVER_mst_receive(cs->msgtok, cs, cs->pending_inbound_msg->buf,cs->pending_inbound_msg.bytes_recv, GNUNET_YES, GNUNET_NO); - res = GNUNET_OK; - if ((res != GNUNET_SYSERR) && (res != GNUNET_NO)) send_error_to_client = GNUNET_NO; - } + if (send_error_to_client == GNUNET_NO) { response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),HTTP_PUT_RESPONSE, MHD_NO, MHD_NO); @@ -647,6 +636,7 @@ http_server_daemon_prepare (void * cls, struct MHD_Daemon *daemon_handle) struct GNUNET_TIME_Relative tv; GNUNET_assert(cls !=NULL); + ret = GNUNET_SCHEDULER_NO_TASK; FD_ZERO(&rs); FD_ZERO(&ws); FD_ZERO(&es); @@ -1120,10 +1110,13 @@ http_plugin_send (void *cls, address = NULL; cs = GNUNET_CONTAINER_multihashmap_get (plugin->sessions, &target->hashPubKey); + if (cs != NULL) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Session `%s' found\n", GNUNET_i2s(target)); + if ( cs == NULL) { cs = create_session(plugin, (char *) addr, addrlen, NULL, 0, target); - cs->is_active = GNUNET_YES; res = GNUNET_CONTAINER_multihashmap_put ( plugin->sessions, &cs->partner.hashPubKey, cs, @@ -1132,9 +1125,6 @@ http_plugin_send (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Session `%s' inserted\n", GNUNET_i2s(target)); } - if (cs != NULL) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Session `%s' found\n", GNUNET_i2s(target)); GNUNET_assert ((addr!=NULL) && (addrlen != 0)); if (addrlen == (sizeof (struct IPv4HttpAddress))) diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index 6042ad154..4e70dc52e 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -983,17 +983,12 @@ static void run_connection_tests( ) port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address, port); } - else if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) + if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress))) { inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN); port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address,port); } - else - { - GNUNET_break (0); - return; - } msg.type=htons(type); memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, &fail_msgs_transmited_to_local_addrs); @@ -1021,7 +1016,7 @@ static void run_connection_tests( ) msg1->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); msg1->type = htons(40); msg2 = &msg1[2]; - msg2->size = htons(3 * sizeof(struct GNUNET_MessageHeader)); + msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader)); msg2->type = htons(41); api->send(api->cls, &my_identity, tmp, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, NULL); @@ -1040,13 +1035,14 @@ static void run_connection_tests( ) /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE )*/ + /* GNUNET_free(tmp); tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE); uint16_t t2 = (uint16_t)GNUNET_SERVER_MAX_MESSAGE_SIZE; msg.size = htons(t2); memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader)); api->send(api->cls, &my_identity, tmp, GNUNET_SERVER_MAX_MESSAGE_SIZE, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_YES, &task_send_cont, &fail_msg_transmited_bigger_max_size); - +*/ /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1 */ GNUNET_free(tmp); tmp = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE-1);