diff options
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/buffer.c b/src/buffer.c index 04419e7..e6d4ce8 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
@@ -138,8 +138,7 @@ int sendraw(p_buf buf, const char *data, size_t count, size_t *sent) | |||
138 | int err = IO_DONE; | 138 | int err = IO_DONE; |
139 | while (total < count && err == IO_DONE) { | 139 | while (total < count && err == IO_DONE) { |
140 | size_t done; | 140 | size_t done; |
141 | err = io->send(io->ctx, data+total, count-total, &done, | 141 | err = io->send(io->ctx, data+total, count-total, &done, tm_get(tm)); |
142 | tm_getsuccess(tm)); | ||
143 | total += done; | 142 | total += done; |
144 | } | 143 | } |
145 | *sent = total; | 144 | *sent = total; |
@@ -156,7 +155,7 @@ int recvraw(lua_State *L, p_buf buf, size_t wanted) | |||
156 | size_t total = 0; | 155 | size_t total = 0; |
157 | luaL_Buffer b; | 156 | luaL_Buffer b; |
158 | luaL_buffinit(L, &b); | 157 | luaL_buffinit(L, &b); |
159 | while (total < wanted && err == IO_DONE) { | 158 | while (total < wanted && (err == IO_DONE || err == IO_RETRY)) { |
160 | size_t count; const char *data; | 159 | size_t count; const char *data; |
161 | err = buf_get(buf, &data, &count); | 160 | err = buf_get(buf, &data, &count); |
162 | count = MIN(count, wanted - total); | 161 | count = MIN(count, wanted - total); |
@@ -177,7 +176,7 @@ int recvall(lua_State *L, p_buf buf) | |||
177 | int err = IO_DONE; | 176 | int err = IO_DONE; |
178 | luaL_Buffer b; | 177 | luaL_Buffer b; |
179 | luaL_buffinit(L, &b); | 178 | luaL_buffinit(L, &b); |
180 | while (err == IO_DONE) { | 179 | while (err == IO_DONE || err == IO_RETRY) { |
181 | const char *data; size_t count; | 180 | const char *data; size_t count; |
182 | err = buf_get(buf, &data, &count); | 181 | err = buf_get(buf, &data, &count); |
183 | luaL_addlstring(&b, data, count); | 182 | luaL_addlstring(&b, data, count); |
@@ -197,7 +196,7 @@ int recvline(lua_State *L, p_buf buf) | |||
197 | int err = IO_DONE; | 196 | int err = IO_DONE; |
198 | luaL_Buffer b; | 197 | luaL_Buffer b; |
199 | luaL_buffinit(L, &b); | 198 | luaL_buffinit(L, &b); |
200 | while (err == IO_DONE) { | 199 | while (err == IO_DONE || err == IO_RETRY) { |
201 | size_t count, pos; const char *data; | 200 | size_t count, pos; const char *data; |
202 | err = buf_get(buf, &data, &count); | 201 | err = buf_get(buf, &data, &count); |
203 | pos = 0; | 202 | pos = 0; |
@@ -240,8 +239,7 @@ int buf_get(p_buf buf, const char **data, size_t *count) | |||
240 | p_tm tm = buf->tm; | 239 | p_tm tm = buf->tm; |
241 | if (buf_isempty(buf)) { | 240 | if (buf_isempty(buf)) { |
242 | size_t got; | 241 | size_t got; |
243 | err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, | 242 | err = io->recv(io->ctx, buf->data, BUF_SIZE, &got, tm_get(tm)); |
244 | tm_getsuccess(tm)); | ||
245 | buf->first = 0; | 243 | buf->first = 0; |
246 | buf->last = got; | 244 | buf->last = got; |
247 | } | 245 | } |