aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r--src/transport/plugin_transport_http.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index f71acf4b0..2ece30433 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -568,26 +568,21 @@ int mhd_send_callback (void *cls, uint64_t pos, char *buf, int max)
568 568
569 if (msg!=NULL) 569 if (msg!=NULL)
570 { 570 {
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"mhd_send_callback %X: queue msg size: %u, max %u pos %u msg->pos %u\n",ps,msg->size,max,pos,msg->pos);
572 if ((msg->size-msg->pos) <= max) 571 if ((msg->size-msg->pos) <= max)
573 { 572 {
574 memcpy(buf,&msg->buf[msg->pos],(msg->size-msg->pos)); 573 memcpy(buf,&msg->buf[msg->pos],(msg->size-msg->pos));
575 bytes_read = msg->size-msg->pos; 574 bytes_read = msg->size-msg->pos;
576 msg->pos+=(msg->size-msg->pos); 575 msg->pos+=(msg->size-msg->pos);
577 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"mhd_send_callback %X: complete: size %u pos %u bytes read %u \n",ps,msg->size,msg->pos,bytes_read);
578 } 576 }
579 else 577 else
580 { 578 {
581 memcpy(buf,&msg->buf[msg->pos],max); 579 memcpy(buf,&msg->buf[msg->pos],max);
582 msg->pos+=max; 580 msg->pos+=max;
583 bytes_read = max; 581 bytes_read = max;
584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"mhd_send_callback %X: partial: size %u pos %u bytes read %u \n",ps,msg->size,msg->pos,bytes_read);
585 } 582 }
586 583
587 if (msg->pos==msg->size) 584 if (msg->pos==msg->size)
588 { 585 {
589 struct GNUNET_MessageHeader * tmp = (struct GNUNET_MessageHeader *) msg->buf;
590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"MHD SENT MESSAGE %u bytes msg->type %u msg->size %u\n", bytes_read, ntohs(tmp->type), ntohs(tmp->size));
591 if (NULL!=msg->transmit_cont) 586 if (NULL!=msg->transmit_cont)
592 msg->transmit_cont (msg->transmit_cont_cls,&pc->identity,GNUNET_OK); 587 msg->transmit_cont (msg->transmit_cont_cls,&pc->identity,GNUNET_OK);
593 res = remove_http_message(ps,msg); 588 res = remove_http_message(ps,msg);
@@ -1143,11 +1138,7 @@ static size_t curl_receive_cb( void *stream, size_t size, size_t nmemb, void *pt
1143#if DEBUG_CONNECTIONS 1138#if DEBUG_CONNECTIONS
1144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes received\n",ps, size*nmemb); 1139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes received\n",ps, size*nmemb);
1145#endif 1140#endif
1146 1141 GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, GNUNET_NO);
1147 struct GNUNET_MessageHeader * msg = stream;
1148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes msg->type %u msg->size %u\n",ps, size*nmemb, ntohs(msg->type), ntohs(msg->size));
1149
1150 // GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, GNUNET_NO);
1151 return (size * nmemb); 1142 return (size * nmemb);
1152 1143
1153} 1144}
@@ -1712,37 +1703,41 @@ http_plugin_disconnect (void *cls,
1712 struct Plugin *plugin = cls; 1703 struct Plugin *plugin = cls;
1713 struct HTTP_PeerContext *pc = NULL; 1704 struct HTTP_PeerContext *pc = NULL;
1714 struct Session *ps = NULL; 1705 struct Session *ps = NULL;
1706 //struct Session *tmp = NULL;
1715 1707
1716 pc = GNUNET_CONTAINER_multihashmap_get (plugin->peers, &target->hashPubKey); 1708 pc = GNUNET_CONTAINER_multihashmap_get (plugin->peers, &target->hashPubKey);
1717 if (pc==NULL) 1709 if (pc==NULL)
1718 return; 1710 return;
1719
1720 ps = pc->head; 1711 ps = pc->head;
1721 1712
1722 while (ps!=NULL) 1713 while (ps!=NULL)
1723 { 1714 {
1715
1724 if (ps->direction==OUTBOUND) 1716 if (ps->direction==OUTBOUND)
1725 { 1717 {
1718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"connections %X\n", ps, GNUNET_i2s(target));
1726 if (ps->send_endpoint!=NULL) 1719 if (ps->send_endpoint!=NULL)
1727 { 1720 {
1728 curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint); 1721 //curl_multi_remove_handle(plugin->multi_handle,ps->send_endpoint);
1729 curl_easy_cleanup(ps->send_endpoint); 1722 //curl_easy_cleanup(ps->send_endpoint);
1730 ps->send_endpoint=NULL; 1723 //ps->send_endpoint=NULL;
1731 ps->send_force_disconnect = GNUNET_YES; 1724 ps->send_force_disconnect = GNUNET_YES;
1732 } 1725 }
1733 if (ps->recv_endpoint!=NULL) 1726 if (ps->recv_endpoint!=NULL)
1734 { 1727 {
1735 curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint); 1728 //curl_multi_remove_handle(plugin->multi_handle,ps->recv_endpoint);
1736 curl_easy_cleanup(ps->recv_endpoint); 1729 //curl_easy_cleanup(ps->recv_endpoint);
1737 ps->recv_endpoint=NULL; 1730 //ps->recv_endpoint=NULL;
1738 ps->recv_force_disconnect = GNUNET_YES; 1731 ps->recv_force_disconnect = GNUNET_YES;
1739 } 1732 }
1740 } 1733 }
1734
1741 if (ps->direction==INBOUND) 1735 if (ps->direction==INBOUND)
1742 { 1736 {
1743 ps->recv_force_disconnect = GNUNET_YES; 1737 ps->recv_force_disconnect = GNUNET_YES;
1744 ps->send_force_disconnect = GNUNET_YES; 1738 ps->send_force_disconnect = GNUNET_YES;
1745 } 1739 }
1740
1746 while (ps->pending_msgs_head!=NULL) 1741 while (ps->pending_msgs_head!=NULL)
1747 { 1742 {
1748 remove_http_message(ps, ps->pending_msgs_head); 1743 remove_http_message(ps, ps->pending_msgs_head);
@@ -1751,7 +1746,6 @@ http_plugin_disconnect (void *cls,
1751 ps->send_active = GNUNET_NO; 1746 ps->send_active = GNUNET_NO;
1752 ps=ps->next; 1747 ps=ps->next;
1753 } 1748 }
1754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"All connections to peer `%s' terminated\n", GNUNET_i2s(target));
1755} 1749}
1756 1750
1757 1751