Lines Matching defs:str
47 static int copyvec(evStream *str, const struct iovec *iov, int iocnt);
48 static void consume(evStream *str, size_t bytes);
49 static void done(evContext opaqueCtx, evStream *str);
135 evStream *str = id.opaque;
139 str->timer = timer;
140 str->flags |= EV_STR_TIMEROK;
146 evStream *str = id.opaque;
150 str->flags &= ~EV_STR_TIMEROK;
210 copyvec(evStream *str, const struct iovec *iov, int iocnt) {
213 str->iovOrig = (struct iovec *)memget(sizeof(struct iovec) * iocnt);
214 if (str->iovOrig == NULL) {
218 str->ioTotal = 0;
220 str->iovOrig[i] = iov[i];
221 str->ioTotal += iov[i].iov_len;
223 str->iovOrigCount = iocnt;
224 str->iovCur = str->iovOrig;
225 str->iovCurCount = str->iovOrigCount;
226 str->ioDone = 0;
232 consume(evStream *str, size_t bytes) {
234 if (bytes < (size_t)str->iovCur->iov_len) {
235 str->iovCur->iov_len -= bytes;
236 str->iovCur->iov_base = (void *)
237 ((u_char *)str->iovCur->iov_base + bytes);
238 str->ioDone += bytes;
241 bytes -= str->iovCur->iov_len;
242 str->ioDone += str->iovCur->iov_len;
243 str->iovCur++;
244 str->iovCurCount--;
251 done(evContext opaqueCtx, evStream *str) {
255 str->prevDone = ctx->strLast;
256 ctx->strLast->nextDone = str;
257 ctx->strLast = str;
260 ctx->strDone = ctx->strLast = str;
262 evDeselectFD(opaqueCtx, str->file);
263 str->file.opaque = NULL;
270 evStream *str = uap;
275 bytes = writev(fd, str->iovCur, str->iovCurCount);
277 if ((str->flags & EV_STR_TIMEROK) != 0)
278 evTouchIdleTimer(opaqueCtx, str->timer);
279 consume(str, bytes);
282 str->ioDone = -1;
283 str->ioErrno = errno;
286 if (str->ioDone == -1 || str->ioDone == str->ioTotal)
287 done(opaqueCtx, str);
293 evStream *str = uap;
298 bytes = readv(fd, str->iovCur, str->iovCurCount);
300 if ((str->flags & EV_STR_TIMEROK) != 0)
301 evTouchIdleTimer(opaqueCtx, str->timer);
302 consume(str, bytes);
305 str->ioDone = 0;
308 str->ioDone = -1;
309 str->ioErrno = errno;
313 if (str->ioDone <= 0 || str->ioDone == str->ioTotal)
314 done(opaqueCtx, str);