[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/icecream-make-it-cool/services
From:       Dirk Mueller <mueller () kde ! org>
Date:       2007-07-30 20:45:27
Message-ID: 1185828327.379840.24425.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 694480 by mueller:

- implement bulk sending
- reduce overhead by not sending a full path


 M  +41 -6     comm.cpp  
 M  +5 -7      comm.h  


--- branches/work/icecream-make-it-cool/services/comm.cpp #694479:694480
@@ -661,6 +661,15 @@
   return createChannel(remote_fd, (struct sockaddr *)&remote_addr, sizeof( remote_addr ));
 }
 
+static std::string
+shorten_filename(const std::string& str)
+{
+  std::string::size_type ofs = str.rfind('/');
+  if (ofs != string::npos)
+    ofs = str.rfind('/', ofs-1);
+  return str.substr(ofs+1);
+}
+
 bool
 MsgChannel::eq_ip (const MsgChannel &s) const
 {
@@ -821,6 +830,12 @@
 
   int i = 0;
   setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (char*) &i, sizeof(i));
+  // would be nice but not portable accross non-linux and
+  // causes huge delays in case of partial frames (seconds range)
+#if 0
+  i = 1;
+  setsockopt (fd, IPPROTO_TCP, TCP_CORK, (char*) &i, sizeof(i));
+#endif
   i = 65536;
   setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &i, sizeof(i));
 }
@@ -930,7 +945,7 @@
 }
 
 bool
-MsgChannel::send_msg (const Msg &m, enum SendFlags flag)
+MsgChannel::send_msg (const Msg &m, int flags)
 {
   if (instate == NEED_PROTO && !wait_for_protocol ())
     return false;
@@ -947,7 +962,10 @@
       uint32_t len = htonl (msgtogo - msgtogo_old - 4);
       memcpy (msgbuf + msgtogo_old, &len, 4);
     }
-  return flush_writebuf (flag == SendBlocking);
+  if ((flags & SendBulkOnly) && msgtogo < 4096)
+    return true;
+
+  return flush_writebuf ((flags & SendBlocking));
 }
 
 #include "getifaddrs.h"
@@ -1215,7 +1233,7 @@
 {
   Msg::send_to_channel (c);
   c->write_environments( versions );
-  *c << filename;
+  *c << shorten_filename(filename);
   *c << (uint32_t) lang;
   *c << count;
   *c << target;
@@ -1554,7 +1572,15 @@
 void
 MonGetCSMsg::fill_from_channel (MsgChannel *c)
 {
-  GetCSMsg::fill_from_channel (c);
+  if (IS_PROTOCOL_29(c)) {
+    *c >> filename;
+    uint32_t _lang;
+    *c >> _lang;
+    lang = static_cast<CompileJob::Language>(_lang);
+  }
+  else
+    GetCSMsg::fill_from_channel (c);
+
   *c >> job_id;
   *c >> clientid;
 }
@@ -1562,7 +1588,16 @@
 void
 MonGetCSMsg::send_to_channel (MsgChannel *c) const
 {
-  GetCSMsg::send_to_channel (c);
+  if (IS_PROTOCOL_29(c)) {
+    std::string f = filename;
+    if (f.size() > 32)
+      f = f.substr(f.size()-32);
+    *c << f;
+    *c << (uint32_t) lang;
+  }
+  else
+      GetCSMsg::send_to_channel (c);
+
   *c << job_id;
   *c << clientid;
 }
@@ -1600,7 +1635,7 @@
   *c << hostid;
   *c << job_id;
   *c << stime;
-  *c << file;
+  *c << shorten_filename(file);
 }
 
 void
--- branches/work/icecream-make-it-cool/services/comm.h #694479:694480
@@ -50,6 +50,7 @@
 #define IS_PROTOCOL_26( c ) ( (c)->protocol >= 26 )
 #define IS_PROTOCOL_27( c ) ( (c)->protocol >= 27 )
 #define IS_PROTOCOL_28( c ) ( (c)->protocol >= 28 )
+#define IS_PROTOCOL_29( c ) ( (c)->protocol >= 29 )
 
 enum MsgType {
   // so far unknown
@@ -137,8 +138,9 @@
   int fd;
 
   enum SendFlags {
-      SendBlocking = 0,
-      SendNonBlocking = 1<<0
+      SendBlocking    = 1<<0,
+      SendNonBlocking = 1<<1,
+      SendBulkOnly    = 1<<2
   };
 
   // the minimum protocol version between me and him
@@ -153,13 +155,9 @@
   // NULL  <--> channel closed
   Msg *get_msg(int timeout = 10);
   // false <--> error (msg not send)
-  bool send_msg (const Msg &, enum SendFlags = SendBlocking);
+  bool send_msg (const Msg &, int SendFlags = SendBlocking);
   bool has_msg (void) const { return eof || instate == HAS_MSG; }
-  bool need_write (void) const { return msgtogo != 0; }
   bool read_a_bit (void);
-  bool write_a_bit (void) {
-    return need_write () ? flush_writebuf (false) : true;
-  }
   bool at_eof (void) const { return instate != HAS_MSG && eof; }
   bool is_text_based(void) const { return text_based; }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic