+ if (nr > 0)
+ {
+ ptr->read_data_length+= (size_t)nr;
+ ptr->read_buffer_length+= (size_t)nr;
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * If the we have callbacks connected to this server structure
+ * we may start process the input queue and fire the callbacks
+ * for the incomming messages. This function is _only_ called
+ * when the input buffer is full, so that we _know_ that we have
+ * at least _one_ message to process.
+ *
+ * @param ptr the server to star processing iput messages for
+ * @return true if we processed anything, false otherwise
+ */
+static bool process_input_buffer(memcached_server_st *ptr)
+{
+ /*
+ ** We might be able to process some of the response messages if we
+ ** have a callback set up
+ */
+ if (ptr->root->callbacks != NULL && (ptr->root->flags & MEM_USE_UDP) == 0)
+ {
+ /*
+ * We might have responses... try to read them out and fire
+ * callbacks
+ */
+ memcached_callback_st cb= *ptr->root->callbacks;
+
+ char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
+ memcached_return error;
+ error= memcached_response(ptr, buffer, sizeof(buffer),
+ &ptr->root->result);
+ if (error == MEMCACHED_SUCCESS)
+ {
+ for (int x= 0; x < cb.number_of_callback; x++)
+ {
+ error= (*cb.callback[x])(ptr->root, &ptr->root->result, cb.context);
+ if (error != MEMCACHED_SUCCESS)
+ break;
+ }
+
+ /* @todo what should I do with the error message??? */
+ }
+ /* @todo what should I do with other error messages?? */
+ return true;
+ }
+
+ return false;