- /* process data (if available) */
- while (available > 0)
- {
- maxcpy = available;
- if (maxcpy > sizeof (client->incoming_buffer) - client->receive_pos)
- maxcpy = sizeof (client->incoming_buffer) - client->receive_pos;
-#if DEBUG_SERVER
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Can copy %u bytes to private buffer\n", maxcpy);
-#endif
- memcpy (&client->incoming_buffer[client->receive_pos], cbuf, maxcpy);
- client->receive_pos += maxcpy;
- cbuf += maxcpy;
- available -= maxcpy;
- if (0 < client->suspended)
- {
- if (available > 0)
- {
-#if DEBUG_SERVER
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client has suspended processing; copying %u bytes to side buffer to be used later.\n",
- available);
-#endif
- GNUNET_assert (client->side_buf_size == 0);
- GNUNET_assert (client->side_buf == NULL);
- client->side_buf_size = available;
- client->side_buf = GNUNET_malloc (available);
- memcpy (client->side_buf, cbuf, available);
- available = 0;
- }
- break; /* do not run next client iteration! */
- }
-#if DEBUG_SERVER
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Now processing messages in private buffer\n");
-#endif
- process_client_buffer (client);
- }
- GNUNET_assert (available == 0);
- if ((client->suspended == 0) &&
- (GNUNET_YES != client->shutdown_now) && (client->server != NULL))
- {
- /* Finally, keep receiving! */
- client->receive_pending = GNUNET_YES;
- client->receive (client->client_closure,
- GNUNET_SERVER_MAX_MESSAGE_SIZE,
- server->idle_timeout, &process_incoming, client);
- }
- if (GNUNET_YES == client->shutdown_now)
- GNUNET_SERVER_client_disconnect (client);
- GNUNET_SERVER_client_drop (client);