[tracker/dbus-fd-experiment: 6/13] Steroids server: refactor page_flush
- From: Adrien Bustany <abustany src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/dbus-fd-experiment: 6/13] Steroids server: refactor page_flush
- Date: Mon, 24 May 2010 14:29:17 +0000 (UTC)
commit 306e72c4b6d7356c1820a2a0ea5366193efd180b
Author: Adrien Bustany <abustany gnome org>
Date: Fri May 21 12:52:17 2010 -0400
Steroids server: refactor page_flush
This commit puts the sending logic of page_flush in a separate function,
buffer_send.
src/tracker-store/tracker-steroids.c | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/src/tracker-store/tracker-steroids.c b/src/tracker-store/tracker-steroids.c
index 3b47338..2523fad 100644
--- a/src/tracker-store/tracker-steroids.c
+++ b/src/tracker-store/tracker-steroids.c
@@ -110,11 +110,27 @@ client_write_int (ClientInfo *info, int value)
info->send_buffer_index += sizeof (int);
}
+static void
+buffer_send (int fd, char *buf, int size)
+{
+ ssize_t sent = 0;
+
+ while (sent != size) {
+ ssize_t ret = write (fd,
+ buf + sent,
+ size - sent);
+
+ if (ret == -1) {
+ g_critical ("Could not send buffer");
+ }
+
+ sent += ret;
+ }
+}
static void
page_flush (ClientInfo *info)
{
- ssize_t sent = 0;
/* Put an "end of page" marker if there was still some space left
* The "end of page" marker is one byte long, so we're sure there's at
* least space for the marker */
@@ -124,17 +140,7 @@ page_flush (ClientInfo *info)
sizeof (char));
}
- while (sent != SEND_BUFFER_SIZE) {
- ssize_t ret = write (info->fd,
- info->send_buffer + sent,
- SEND_BUFFER_SIZE - sent);
-
- if (ret == -1) {
- g_critical ("Page flush failed");
- }
-
- sent += ret;
- }
+ buffer_send (info-> fd, info->send_buffer, SEND_BUFFER_SIZE);
info->send_buffer_index = 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]