summaryrefslogtreecommitdiffstats
path: root/src/dispatch.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-03-27 15:26:39 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-03-27 15:26:39 -0400
commit662c1484f0bbab1281fde97afde7f35a8e9778f2 (patch)
tree136a798534592b406bebfc199d9dbb90f75e50e4 /src/dispatch.c
parent8f884257d95ea9ebec742b59dc83d7defdae117d (diff)
downloadslapi-nis-662c1484f0bbab1281fde97afde7f35a8e9778f2.tar.gz
slapi-nis-662c1484f0bbab1281fde97afde7f35a8e9778f2.tar.xz
slapi-nis-662c1484f0bbab1281fde97afde7f35a8e9778f2.zip
more cleanup of client-handling code
Diffstat (limited to 'src/dispatch.c')
-rw-r--r--src/dispatch.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/dispatch.c b/src/dispatch.c
index c61b9c3..6e1999a 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -128,7 +128,7 @@ dispatch_stream_handler_thread(void *arg)
continue;
}
/* Convert the fragment length information to local byte order,
- * and check if this is the last fragment in the record. */
+ * and determine if this is the last fragment in the record. */
memcpy(&nlen, fragment, 4);
len = ntohl(nlen);
last = ((len & 0x80000000) != 0);
@@ -143,27 +143,25 @@ dispatch_stream_handler_thread(void *arg)
slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
"in: frag_len=%d,record=%d\n",
frag_len, record_len);
- /* Pull the fragment out of the buffer. */
+ /* Pull the fragment out of the buffer and append it to the
+ * record buffer. */
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"got whole fragment (%d bytes)\n", len);
- /* Append fragment to the record buffer. */
memmove(record + record_len, fragment + 4, len);
record_len += len;
- /* Remove the fragment from the fragment buffer. */
memmove(fragment, fragment + (len + 4), frag_len - (len + 4));
frag_len -= (len + 4);
- /* If this is the last fragment in the record, then we can
- * process the record and reset the record buffer. */
- if (last) {
- slapi_log_error(SLAPI_LOG_PLUGIN,
- state->plugin_desc->spd_id,
- "got whole record (%d bytes)\n",
- record_len);
- nis_process_request(state, client, NULL, 0,
- record, record_len);
- record_len = 0;
+ /* If there are more fragments to come, then we need to wait
+ * for more data. */
+ if (!last) {
+ continue;
}
+ slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id,
+ "got whole record (%d bytes)\n", record_len);
+ nis_process_request(state, client, NULL, 0, record, record_len);
+ record_len = 0;
+ /* Note that we did it! */
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"out: frag_len=%d,record=%d\n",