Lines Matching refs:spc

254 spcresetbuf(struct spclient *spc)  in spcresetbuf()  argument
257 spc->spc_buf = NULL; in spcresetbuf()
258 spc->spc_off = 0; in spcresetbuf()
262 spcfreebuf(struct spclient *spc) in spcfreebuf() argument
265 free(spc->spc_buf); in spcfreebuf()
266 spcresetbuf(spc); in spcfreebuf()
270 sendlockl(struct spclient *spc) in sendlockl() argument
273 while (spc->spc_ostatus != SPCSTATUS_FREE) { in sendlockl()
274 spc->spc_ostatus = SPCSTATUS_WANTED; in sendlockl()
275 pthread_cond_wait(&spc->spc_cv, &spc->spc_mtx); in sendlockl()
277 spc->spc_ostatus = SPCSTATUS_BUSY; in sendlockl()
281 sendlock(struct spclient *spc) in sendlock() argument
284 pthread_mutex_lock(&spc->spc_mtx); in sendlock()
285 sendlockl(spc); in sendlock()
286 pthread_mutex_unlock(&spc->spc_mtx); in sendlock()
290 sendunlockl(struct spclient *spc) in sendunlockl() argument
293 if (spc->spc_ostatus == SPCSTATUS_WANTED) in sendunlockl()
294 pthread_cond_broadcast(&spc->spc_cv); in sendunlockl()
295 spc->spc_ostatus = SPCSTATUS_FREE; in sendunlockl()
299 sendunlock(struct spclient *spc) in sendunlock() argument
302 pthread_mutex_lock(&spc->spc_mtx); in sendunlock()
303 sendunlockl(spc); in sendunlock()
304 pthread_mutex_unlock(&spc->spc_mtx); in sendunlock()
308 dosend(struct spclient *spc, struct iovec *iov, size_t iovlen) in dosend() argument
313 int fd = spc->spc_fd; in dosend()
365 doputwait(struct spclient *spc, struct respwait *rw, struct rsp_hdr *rhdr) in doputwait() argument
372 pthread_mutex_lock(&spc->spc_mtx); in doputwait()
373 rw->rw_reqno = rhdr->rsp_reqno = spc->spc_nextreq++; in doputwait()
374 TAILQ_INSERT_TAIL(&spc->spc_respwait, rw, rw_entries); in doputwait()
378 putwait_locked(struct spclient *spc, struct respwait *rw, struct rsp_hdr *rhdr) in putwait_locked() argument
381 doputwait(spc, rw, rhdr); in putwait_locked()
382 pthread_mutex_unlock(&spc->spc_mtx); in putwait_locked()
386 putwait(struct spclient *spc, struct respwait *rw, struct rsp_hdr *rhdr) in putwait() argument
389 doputwait(spc, rw, rhdr); in putwait()
390 sendlockl(spc); in putwait()
391 pthread_mutex_unlock(&spc->spc_mtx); in putwait()
395 dounputwait(struct spclient *spc, struct respwait *rw) in dounputwait() argument
398 TAILQ_REMOVE(&spc->spc_respwait, rw, rw_entries); in dounputwait()
399 pthread_mutex_unlock(&spc->spc_mtx); in dounputwait()
405 unputwait_locked(struct spclient *spc, struct respwait *rw) in unputwait_locked() argument
408 pthread_mutex_lock(&spc->spc_mtx); in unputwait_locked()
409 dounputwait(spc, rw); in unputwait_locked()
413 unputwait(struct spclient *spc, struct respwait *rw) in unputwait() argument
416 pthread_mutex_lock(&spc->spc_mtx); in unputwait()
417 sendunlockl(spc); in unputwait()
419 dounputwait(spc, rw); in unputwait()
423 kickwaiter(struct spclient *spc) in kickwaiter() argument
428 pthread_mutex_lock(&spc->spc_mtx); in kickwaiter()
429 TAILQ_FOREACH(rw, &spc->spc_respwait, rw_entries) { in kickwaiter()
430 if (rw->rw_reqno == spc->spc_hdr.rsp_reqno) in kickwaiter()
435 spc->spc_hdr.rsp_reqno)); in kickwaiter()
436 pthread_mutex_unlock(&spc->spc_mtx); in kickwaiter()
437 spcfreebuf(spc); in kickwaiter()
440 DPRINTF(("rump_sp: client %p woke up waiter at %p\n", spc, rw)); in kickwaiter()
441 rw->rw_data = spc->spc_buf; in kickwaiter()
443 rw->rw_dlen = (size_t)(spc->spc_off - HDRSZ); in kickwaiter()
444 if (spc->spc_hdr.rsp_class == RUMPSP_ERROR) { in kickwaiter()
445 error = rw->rw_error = errmap(spc->spc_hdr.rsp_error); in kickwaiter()
448 pthread_mutex_unlock(&spc->spc_mtx); in kickwaiter()
451 spcfreebuf(spc); in kickwaiter()
453 spcresetbuf(spc); in kickwaiter()
457 kickall(struct spclient *spc) in kickall() argument
462 TAILQ_FOREACH(rw, &spc->spc_respwait, rw_entries) in kickall()
467 readframe(struct spclient *spc) in readframe() argument
469 int fd = spc->spc_fd; in readframe()
475 if (spc->spc_off < HDRSZ) { in readframe()
477 spc->spc_off)); in readframe()
479 left = HDRSZ - spc->spc_off; in readframe()
481 n = host_read(fd, (uint8_t*)&spc->spc_hdr + spc->spc_off, left); in readframe()
491 spc->spc_off += n; in readframe()
492 if (spc->spc_off < HDRSZ) { in readframe()
497 framelen = spc->spc_hdr.rsp_len; in readframe()
506 spc->spc_buf = malloc(framelen - HDRSZ + 1); in readframe()
507 if (spc->spc_buf == NULL) { in readframe()
510 memset(spc->spc_buf, 0, framelen - HDRSZ + 1); in readframe()
515 framelen = spc->spc_hdr.rsp_len; in readframe()
518 left = framelen - spc->spc_off; in readframe()
521 spc->spc_off, left)); in readframe()
525 n = host_read(fd, spc->spc_buf + (spc->spc_off - HDRSZ), left); in readframe()
534 spc->spc_off += n; in readframe()