diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-07-02 13:00:36 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-07-02 13:00:36 +0000 |
commit | 4a789496f1b7a453c247b99994839e759155e7b9 (patch) | |
tree | fde32cd4adcc5e95d60a196ab692e8a578d26fb6 /src/util/connection.c | |
parent | 1d938adb4c5c015d6bdef0047177641c808746b7 (diff) | |
download | gnunet-4a789496f1b7a453c247b99994839e759155e7b9.tar.gz gnunet-4a789496f1b7a453c247b99994839e759155e7b9.zip |
remove max buffer size from everywhere in util
Diffstat (limited to 'src/util/connection.c')
-rw-r--r-- | src/util/connection.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/src/util/connection.c b/src/util/connection.c index 34c9fa62b..b1e68b0ef 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -214,11 +214,6 @@ struct GNUNET_CONNECTION_Handle | |||
214 | char *write_buffer; | 214 | char *write_buffer; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Max size of our write buffer. | ||
218 | */ | ||
219 | size_t max_write_buffer_size; | ||
220 | |||
221 | /** | ||
222 | * Current size of our write buffer. | 217 | * Current size of our write buffer. |
223 | */ | 218 | */ |
224 | size_t write_buffer_size; | 219 | size_t write_buffer_size; |
@@ -319,21 +314,17 @@ void GNUNET_CONNECTION_persist_(struct GNUNET_CONNECTION_Handle *sock) | |||
319 | * | 314 | * |
320 | * @param sched scheduler to use | 315 | * @param sched scheduler to use |
321 | * @param osSocket existing socket to box | 316 | * @param osSocket existing socket to box |
322 | * @param maxbuf maximum write buffer size for the socket (use | ||
323 | * 0 for sockets that need no write buffers, such as listen sockets) | ||
324 | * @return the boxed socket handle | 317 | * @return the boxed socket handle |
325 | */ | 318 | */ |
326 | struct GNUNET_CONNECTION_Handle * | 319 | struct GNUNET_CONNECTION_Handle * |
327 | GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle | 320 | GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle |
328 | *sched, | 321 | *sched, |
329 | struct GNUNET_NETWORK_Handle | 322 | struct GNUNET_NETWORK_Handle |
330 | *osSocket, size_t maxbuf) | 323 | *osSocket) |
331 | { | 324 | { |
332 | struct GNUNET_CONNECTION_Handle *ret; | 325 | struct GNUNET_CONNECTION_Handle *ret; |
333 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 326 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); |
334 | GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
335 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 327 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
336 | ret->max_write_buffer_size = maxbuf; | ||
337 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 328 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
338 | ret->sock = osSocket; | 329 | ret->sock = osSocket; |
339 | ret->sched = sched; | 330 | ret->sched = sched; |
@@ -349,8 +340,6 @@ GNUNET_CONNECTION_create_from_existing (struct GNUNET_SCHEDULER_Handle | |||
349 | * @param access function to use to check if access is allowed | 340 | * @param access function to use to check if access is allowed |
350 | * @param access_cls closure for access | 341 | * @param access_cls closure for access |
351 | * @param lsock listen socket | 342 | * @param lsock listen socket |
352 | * @param maxbuf maximum write buffer size for the socket (use | ||
353 | * 0 for sockets that need no write buffers, such as listen sockets) | ||
354 | * @return the socket handle, NULL on error | 343 | * @return the socket handle, NULL on error |
355 | */ | 344 | */ |
356 | struct GNUNET_CONNECTION_Handle * | 345 | struct GNUNET_CONNECTION_Handle * |
@@ -358,8 +347,7 @@ GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle | |||
358 | *sched, | 347 | *sched, |
359 | GNUNET_CONNECTION_AccessCheck access, | 348 | GNUNET_CONNECTION_AccessCheck access, |
360 | void *access_cls, | 349 | void *access_cls, |
361 | struct GNUNET_NETWORK_Handle *lsock, | 350 | struct GNUNET_NETWORK_Handle *lsock) |
362 | size_t maxbuf) | ||
363 | { | 351 | { |
364 | struct GNUNET_CONNECTION_Handle *ret; | 352 | struct GNUNET_CONNECTION_Handle *ret; |
365 | char addr[128]; | 353 | char addr[128]; |
@@ -423,10 +411,7 @@ GNUNET_CONNECTION_create_from_accept (struct GNUNET_SCHEDULER_Handle | |||
423 | return NULL; | 411 | return NULL; |
424 | } | 412 | } |
425 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 413 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); |
426 | |||
427 | GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
428 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 414 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
429 | ret->max_write_buffer_size = maxbuf; | ||
430 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 415 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
431 | ret->addr = uaddr; | 416 | ret->addr = uaddr; |
432 | ret->addrlen = addrlen; | 417 | ret->addrlen = addrlen; |
@@ -870,16 +855,13 @@ try_connect_using_address (void *cls, | |||
870 | * @param cfg configuration to use | 855 | * @param cfg configuration to use |
871 | * @param hostname name of the host to connect to | 856 | * @param hostname name of the host to connect to |
872 | * @param port port to connect to | 857 | * @param port port to connect to |
873 | * @param maxbuf maximum write buffer size for the socket (use | ||
874 | * 0 for sockets that need no write buffers, such as listen sockets) | ||
875 | * @return the socket handle | 858 | * @return the socket handle |
876 | */ | 859 | */ |
877 | struct GNUNET_CONNECTION_Handle * | 860 | struct GNUNET_CONNECTION_Handle * |
878 | GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | 861 | GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, |
879 | const struct | 862 | const struct |
880 | GNUNET_CONFIGURATION_Handle *cfg, | 863 | GNUNET_CONFIGURATION_Handle *cfg, |
881 | const char *hostname, uint16_t port, | 864 | const char *hostname, uint16_t port) |
882 | size_t maxbuf) | ||
883 | { | 865 | { |
884 | struct GNUNET_CONNECTION_Handle *ret; | 866 | struct GNUNET_CONNECTION_Handle *ret; |
885 | 867 | ||
@@ -887,10 +869,7 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
887 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 869 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); |
888 | ret->cfg = cfg; | 870 | ret->cfg = cfg; |
889 | ret->sched = sched; | 871 | ret->sched = sched; |
890 | |||
891 | GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
892 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 872 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
893 | ret->max_write_buffer_size = maxbuf; | ||
894 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 873 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
895 | ret->port = port; | 874 | ret->port = port; |
896 | ret->hostname = GNUNET_strdup (hostname); | 875 | ret->hostname = GNUNET_strdup (hostname); |
@@ -912,16 +891,13 @@ GNUNET_CONNECTION_create_from_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
912 | * @param sched scheduler to use | 891 | * @param sched scheduler to use |
913 | * @param cfg configuration to use | 892 | * @param cfg configuration to use |
914 | * @param unixpath path to connect to | 893 | * @param unixpath path to connect to |
915 | * @param maxbuf maximum write buffer size for the socket (use | ||
916 | * 0 for sockets that need no write buffers, such as listen sockets) | ||
917 | * @return the socket handle, NULL on systems without UNIX support | 894 | * @return the socket handle, NULL on systems without UNIX support |
918 | */ | 895 | */ |
919 | struct GNUNET_CONNECTION_Handle * | 896 | struct GNUNET_CONNECTION_Handle * |
920 | GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, | 897 | GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handle *sched, |
921 | const struct | 898 | const struct |
922 | GNUNET_CONFIGURATION_Handle *cfg, | 899 | GNUNET_CONFIGURATION_Handle *cfg, |
923 | const char *unixpath, | 900 | const char *unixpath) |
924 | size_t maxbuf) | ||
925 | { | 901 | { |
926 | #ifdef AF_UNIX | 902 | #ifdef AF_UNIX |
927 | struct GNUNET_CONNECTION_Handle *ret; | 903 | struct GNUNET_CONNECTION_Handle *ret; |
@@ -946,9 +922,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl | |||
946 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); | 922 | ret = GNUNET_malloc (sizeof (struct GNUNET_CONNECTION_Handle)); |
947 | ret->cfg = cfg; | 923 | ret->cfg = cfg; |
948 | ret->sched = sched; | 924 | ret->sched = sched; |
949 | GNUNET_assert (maxbuf < GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
950 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; | 925 | ret->write_buffer_size = GNUNET_SERVER_MIN_BUFFER_SIZE; |
951 | ret->max_write_buffer_size = maxbuf; | ||
952 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); | 926 | ret->write_buffer = GNUNET_malloc(ret->write_buffer_size); |
953 | ret->port = 0; | 927 | ret->port = 0; |
954 | ret->hostname = NULL; | 928 | ret->hostname = NULL; |
@@ -987,15 +961,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (struct GNUNET_SCHEDULER_Handl | |||
987 | * @param af_family address family to use | 961 | * @param af_family address family to use |
988 | * @param serv_addr server address | 962 | * @param serv_addr server address |
989 | * @param addrlen length of server address | 963 | * @param addrlen length of server address |
990 | * @param maxbuf maximum write buffer size for the socket (use | ||
991 | * 0 for sockets that need no write buffers, such as listen sockets) | ||
992 | * @return the socket handle | 964 | * @return the socket handle |
993 | */ | 965 | */ |
994 | struct GNUNET_CONNECTION_Handle * | 966 | struct GNUNET_CONNECTION_Handle * |
995 | GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle | 967 | GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle |
996 | *sched, int af_family, | 968 | *sched, int af_family, |
997 | const struct sockaddr *serv_addr, | 969 | const struct sockaddr *serv_addr, |
998 | socklen_t addrlen, size_t maxbuf) | 970 | socklen_t addrlen) |
999 | { | 971 | { |
1000 | struct GNUNET_NETWORK_Handle *s; | 972 | struct GNUNET_NETWORK_Handle *s; |
1001 | struct GNUNET_CONNECTION_Handle *ret; | 973 | struct GNUNET_CONNECTION_Handle *ret; |
@@ -1015,7 +987,7 @@ GNUNET_CONNECTION_create_from_sockaddr (struct GNUNET_SCHEDULER_Handle | |||
1015 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); | 987 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); |
1016 | return NULL; | 988 | return NULL; |
1017 | } | 989 | } |
1018 | ret = GNUNET_CONNECTION_create_from_existing (sched, s, maxbuf); | 990 | ret = GNUNET_CONNECTION_create_from_existing (sched, s); |
1019 | ret->addr = GNUNET_malloc (addrlen); | 991 | ret->addr = GNUNET_malloc (addrlen); |
1020 | memcpy (ret->addr, serv_addr, addrlen); | 992 | memcpy (ret->addr, serv_addr, addrlen); |
1021 | ret->addrlen = addrlen; | 993 | ret->addrlen = addrlen; |
@@ -1615,11 +1587,11 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle | |||
1615 | if (sock->nth.notify_ready != NULL) | 1587 | if (sock->nth.notify_ready != NULL) |
1616 | return NULL; | 1588 | return NULL; |
1617 | GNUNET_assert (notify != NULL); | 1589 | GNUNET_assert (notify != NULL); |
1618 | if ((sock->write_buffer_size < size) && (size < sock->max_write_buffer_size)) | 1590 | if ((sock->write_buffer_size < size) && (size < GNUNET_SERVER_MAX_MESSAGE_SIZE)) |
1619 | { | 1591 | { |
1620 | temp_size = sock->write_buffer_size + size; | 1592 | temp_size = sock->write_buffer_size + size; |
1621 | if (temp_size > sock->max_write_buffer_size) | 1593 | if (temp_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) |
1622 | temp_size = sock->max_write_buffer_size; | 1594 | temp_size = GNUNET_SERVER_MAX_MESSAGE_SIZE; |
1623 | 1595 | ||
1624 | sock->write_buffer = GNUNET_realloc(sock->write_buffer, temp_size); | 1596 | sock->write_buffer = GNUNET_realloc(sock->write_buffer, temp_size); |
1625 | sock->write_buffer_size = temp_size; | 1597 | sock->write_buffer_size = temp_size; |