/**
* The maximum packet size of a stream packet
*/
-#define MAX_PACKET_SIZE 64000
+#define MAX_PACKET_SIZE 512//64000
/**
* Receive buffer
/* Now send new packets if there is enough buffer space */
while ( (NULL != io_handle->messages[packet]) &&
(socket->receiver_window_available
- >= ntohs (io_handle->messages[packet]->header.header.size)) )
+ >= ntohs (io_handle->messages[packet]->header.header.size)) &&
+ (packet < GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH))
{
socket->receiver_window_available -=
ntohs (io_handle->messages[packet]->header.header.size);
GNUNET_i2s (&socket->other_peer), sequence_increase);
/* Shift the data in the receive buffer */
- memmove (socket->receive_buffer,
- socket->receive_buffer
- + socket->receive_buffer_boundaries[sequence_increase-1],
- socket->receive_buffer_size
- - socket->receive_buffer_boundaries[sequence_increase-1]);
+ socket->receive_buffer =
+ memmove (socket->receive_buffer,
+ socket->receive_buffer
+ + socket->receive_buffer_boundaries[sequence_increase-1],
+ socket->receive_buffer_size
+ - socket->receive_buffer_boundaries[sequence_increase-1]);
/* Shift the bitmap */
socket->ack_bitmap = socket->ack_bitmap >> sequence_increase;
/* Set read_sequence_number */
{
if (packet < GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH - sequence_increase)
{
- socket->receive_buffer_boundaries[packet] =
- socket->receive_buffer_boundaries[packet + sequence_increase]
- - offset_increase;
+ uint32_t ahead_buffer_boundary;
+
+ ahead_buffer_boundary =
+ socket->receive_buffer_boundaries[packet + sequence_increase];
+ if (0 == ahead_buffer_boundary)
+ socket->receive_buffer_boundaries[packet] = 0;
+ else
+ {
+ GNUNET_assert (offset_increase < ahead_buffer_boundary);
+ socket->receive_buffer_boundaries[packet] =
+ ahead_buffer_boundary - offset_increase;
+ }
}
else
socket->receive_buffer_boundaries[packet] = 0;
}
else /* We have to call the write continuation callback now */
{
+ struct GNUNET_STREAM_IOWriteHandle *write_handle;
+
/* Free the packets */
for (packet=0; packet < GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH; packet++)
{
GNUNET_free_non_null (socket->write_handle->messages[packet]);
}
- if (NULL != socket->write_handle->write_cont)
- socket->write_handle->write_cont
- (socket->write_handle->write_cont_cls,
- socket->status,
- socket->write_handle->size);
+ write_handle = socket->write_handle;
+ socket->write_handle = NULL;
+ if (NULL != write_handle->write_cont)
+ write_handle->write_cont (write_handle->write_cont_cls,
+ socket->status,
+ write_handle->size);
+ /* We are done with the write handle - Freeing it */
+ GNUNET_free (write_handle);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"%s: Write completion callback completed\n",
- GNUNET_i2s (&socket->other_peer));
- /* We are done with the write handle - Freeing it */
- GNUNET_free (socket->write_handle);
- socket->write_handle = NULL;
+ GNUNET_i2s (&socket->other_peer));
}
break;
default:
} while (GNUNET_STREAM_OPTION_END != option);
va_end (vargs); /* End of variable args parsing */
socket->mesh = GNUNET_MESH_connect (cfg, /* the configuration handle */
- 10, /* QUEUE size as parameter? */
+ RECEIVE_BUFFER_SIZE, /* QUEUE size as parameter? */
socket, /* cls */
NULL, /* No inbound tunnel handler */
NULL, /* No in-tunnel cleaner */
lsocket->listen_cb = listen_cb;
lsocket->listen_cb_cls = listen_cb_cls;
lsocket->mesh = GNUNET_MESH_connect (cfg,
- 10, /* FIXME: QUEUE size as parameter? */
+ RECEIVE_BUFFER_SIZE, /* FIXME: QUEUE size as parameter? */
lsocket, /* Closure */
&new_tunnel_notify,
&tunnel_cleaner,