src/server/util/netbuf.c

changeset 385
a1f4cb076d2f
parent 330
71b652743871
equal deleted inserted replaced
210:21274e5950af 385:a1f4cb076d2f
139 139
140 memcpy(buffer, &(buf->inbuf[buf->pos]), bytes_in_buffer); 140 memcpy(buffer, &(buf->inbuf[buf->pos]), bytes_in_buffer);
141 141
142 buf->pos += bytes_in_buffer; 142 buf->pos += bytes_in_buffer;
143 return bytes_in_buffer; 143 return bytes_in_buffer;
144 } else if(buf->pos >= buf->maxsize) {
145 return NETBUF_EOF;
144 } 146 }
145 } 147 }
146 148
149 if(!buf->sd) {
150 return NETBUF_EOF;
151 }
152
147 /* The netbuf is empty. Read data directly into the caller's buffer */ 153 /* The netbuf is empty. Read data directly into the caller's buffer */
148 bytes = net_read(buf->sd, buffer, size); 154 bytes = net_read(buf->sd, buffer, size);
149 if (bytes == 0) 155 if (bytes == 0)
150 return NETBUF_EOF; 156 return NETBUF_EOF;
151 if (bytes < 0) { 157 if (bytes < 0) {

mercurial