aboutsummaryrefslogtreecommitdiff
path: root/src/util/connection.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-07-02 16:41:31 +0000
committerNathan S. Evans <evans@in.tum.de>2010-07-02 16:41:31 +0000
commit4238e624cf345537e26c0111418dcd53bc5c1a97 (patch)
tree0665f48539d6754881496979de77fbb7c5c507b2 /src/util/connection.c
parent5f3520842f7f9fa3b35d7afd96b4b963cc0fcd91 (diff)
downloadgnunet-4238e624cf345537e26c0111418dcd53bc5c1a97.tar.gz
gnunet-4238e624cf345537e26c0111418dcd53bc5c1a97.zip
thought realloc was problem, but not properly freeing memory. believe that transport segfault *could* be related to growing connection buffers on demand... appreciate another look if someone has the time (Christian...)
Diffstat (limited to 'src/util/connection.c')
-rw-r--r--src/util/connection.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/util/connection.c b/src/util/connection.c
index 7f2787e18..e8a7453d2 100644
--- a/src/util/connection.c
+++ b/src/util/connection.c
@@ -556,6 +556,7 @@ destroy_continuation (void *cls,
556 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 556 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
557 "Freeing memory of connection %p.\n", sock); 557 "Freeing memory of connection %p.\n", sock);
558#endif 558#endif
559 GNUNET_free (sock->write_buffer);
559 GNUNET_free (sock); 560 GNUNET_free (sock);
560} 561}
561 562
@@ -1586,16 +1587,25 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle
1586 notify, void *notify_cls) 1587 notify, void *notify_cls)
1587{ 1588{
1588 size_t temp_size; 1589 size_t temp_size;
1590#if !REALLOC
1591 char *temp_buf;
1592#endif
1589 if (sock->nth.notify_ready != NULL) 1593 if (sock->nth.notify_ready != NULL)
1590 return NULL; 1594 return NULL;
1591 GNUNET_assert (notify != NULL); 1595 GNUNET_assert (notify != NULL);
1592 if ((sock->write_buffer_size < size) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE)) 1596 if ((sock->write_buffer_size < size) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE))
1593 { 1597 {
1594 temp_size = sock->write_buffer_size + size; 1598 temp_size = sock->write_buffer_size + size + 1;
1595 if (temp_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 1599 if (temp_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1596 temp_size = GNUNET_SERVER_MAX_MESSAGE_SIZE; 1600 temp_size = GNUNET_SERVER_MAX_MESSAGE_SIZE;
1597 1601#if REALLOC
1598 sock->write_buffer = GNUNET_realloc(sock->write_buffer, temp_size); 1602 sock->write_buffer = GNUNET_realloc(sock->write_buffer, temp_size);
1603#else
1604 temp_buf = GNUNET_malloc(temp_size);
1605 memcpy(temp_buf, sock->write_buffer, sock->write_buffer_size);
1606 GNUNET_free(sock->write_buffer);
1607 sock->write_buffer = temp_buf;
1608#endif
1599 sock->write_buffer_size = temp_size; 1609 sock->write_buffer_size = temp_size;
1600 } 1610 }
1601 GNUNET_assert (sock->write_buffer_size >= size); 1611 GNUNET_assert (sock->write_buffer_size >= size);