ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtdaemon.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtdaemon.C (file contents):
Revision 1.9 by root, Sun Dec 25 15:30:29 2005 UTC vs.
Revision 1.10 by root, Sun Dec 25 16:19:34 2005 UTC

30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/utsname.h> 31#include <sys/utsname.h>
32#include <limits.h> 32#include <limits.h>
33 33
34#include "rxvtdaemon.h" 34#include "rxvtdaemon.h"
35
36// works around linux kernel bug, returns EAGAIN on a blocking socket
37static ssize_t
38read_ (int fd, void *buf, size_t count)
39{
40 int ret;
41
42 do
43 ret = read (fd, buf, count);
44 while (ret < 0 && errno == EAGAIN);
45
46 return ret;
47}
48 35
49char *rxvt_connection::unix_sockname () 36char *rxvt_connection::unix_sockname ()
50{ 37{
51 char name[PATH_MAX]; 38 char name[PATH_MAX];
52 char *path = getenv ("RXVT_SOCKET"); 39 char *path = getenv ("RXVT_SOCKET");
85bool rxvt_connection::recv (auto_str &data, int *len) 72bool rxvt_connection::recv (auto_str &data, int *len)
86{ 73{
87 uint8_t s[2]; 74 uint8_t s[2];
88 int l; 75 int l;
89 76
90 if (read_ (fd, s, 2) != 2) 77 if (read (fd, s, 2) != 2)
91 return false; 78 return false;
92 79
93 l = (s[0] << 8) + s[1]; 80 l = (s[0] << 8) + s[1];
94 if (l > 4096) 81 if (l > 4096)
95 return false; 82 return false;
100 data = new char[l + 1]; 87 data = new char[l + 1];
101 88
102 if (!data) 89 if (!data)
103 return false; 90 return false;
104 91
105 if (read_ (fd, data, l) != l) 92 if (read (fd, data, l) != l)
106 return false; 93 return false;
107 94
108 data[l] = 0; 95 data[l] = 0;
109 96
110 return true; 97 return true;
121 108
122bool rxvt_connection::recv (int &data) 109bool rxvt_connection::recv (int &data)
123{ 110{
124 uint8_t s[4]; 111 uint8_t s[4];
125 112
126 if (read_ (fd, s, 4) != 4) 113 if (read (fd, s, 4) != 4)
127 return false; 114 return false;
128 115
129 data = (((((s[0] << 8) | s[1]) << 8) | s[2]) << 8) | s[3]; 116 data = (((((s[0] << 8) | s[1]) << 8) | s[2]) << 8) | s[3];
130 117
131 return true; 118 return true;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines