10 while(lb->wait && lb->rp != lb->wp){
14 lb->waitlast = &lb->wait;
16 if(r->ifcall.count < 5){
17 respond(r, "log read request count too short");
21 lb->msg[lb->rp] = nil;
22 if(++lb->rp == nelem(lb->msg))
25 if(n < strlen(s)+1+1){
26 memmove(r->ofcall.data, s, n-5);
28 r->ofcall.data[n] = '\0';
29 /* look for first byte of UTF-8 sequence by skipping continuation bytes */
30 while(n>0 && (r->ofcall.data[--n]&0xC0)==0x80)
32 strcpy(r->ofcall.data+n, "...\n");
34 strcpy(r->ofcall.data, s);
35 strcat(r->ofcall.data, "\n");
37 r->ofcall.count = strlen(r->ofcall.data);
44 lbread(Logbuf *lb, Req *r)
46 if(lb->waitlast == nil)
47 lb->waitlast = &lb->wait;
49 lb->waitlast = (Req**)(void*)&r->aux;
55 lbflush(Logbuf *lb, Req *r)
59 for(l=&lb->wait; *l; l=(Req**)(void*)&(*l)->aux){
65 respond(r, "interrupted");
72 lbappend(Logbuf *lb, char *fmt, ...)
77 lbvappend(lb, fmt, arg);
82 lbvappend(Logbuf *lb, char *fmt, va_list arg)
86 s = vsmprint(fmt, arg);
88 sysfatal("out of memory");
90 free(lb->msg[lb->wp]);
92 if(++lb->wp == nelem(lb->msg))
102 lbread(&rpclogbuf, r);
108 lbflush(&rpclogbuf, r);
112 rpclog(char *fmt, ...)
117 lbvappend(&rpclogbuf, fmt, arg);