Lines Matching refs:log

103 	int			log;
130 note(Css_t* css, register Connection_t* to, int log, char* s, size_t n, int force, Cssdisc_t* disc)
135 if ((force || to->blocked[log] < 0) && (z = data(state, to, s, n, force)) != n)
140 if (!state->logs[log].sp)
142 state->logs[log].name[0] = '0' + log;
143 remove(state->logs[log].name);
144 if (!(state->logs[log].sp = sfopen(NiL, state->logs[log].name, "r+")))
145 error(ERROR_SYSTEM|3, "%s: cannot create message log", state->logs[log].name);
146 message((-1, "[%d] %s: create log", __LINE__, state->logs[log].name));
148 message((-1, "[%d] %s: %d log", __LINE__, state->logs[log].name, to->fp->fd));
149 if (sfwrite(state->logs[log].sp, s, n) != n)
150 error(ERROR_SYSTEM|3, "%s: log file write error", state->logs[log].name);
151 if ((state->logs[log].offset += n) >= HOG && !state->logs[!log].sp)
152 state->log = !log;
154 if (to->blocked[log] < 0)
156 message((-1, "[%d] %s: block", __LINE__, state->logs[log].name));
157 state->logs[log].blocked++;
159 to->blocked[log] = state->logs[log].offset - n + z;
160 message((-1, "[%d] %s: %d offset %I*d", __LINE__, state->logs[log].name, to->fp->fd, sizeof(to->blocked[log]), to->blocked[log]));
164 if (to->blocked[log] >= 0)
166 message((-1, "[%d] %s: %d unblock", __LINE__, state->logs[log].name, to->fp->fd));
167 to->blocked[log] = -1;
168 if (!--state->logs[log].blocked)
170 sfclose(state->logs[log].sp);
171 state->logs[log].sp = 0;
172 state->logs[log].offset = 0;
173 remove(state->logs[log].name);
174 message((-1, "[%d] %s: clear", __LINE__, state->logs[log].name));
181 dump(Css_t* css, register Connection_t* con, int log, Cssdisc_t* disc)
188 n = state->logs[log].offset - con->blocked[log];
191 if (sfseek(state->logs[log].sp, con->blocked[log], SEEK_SET) != con->blocked[log])
192 error(ERROR_SYSTEM|3, "%s: cannot seek to %I*d", state->logs[log].name, sizeof(con->blocked[log]), con->blocked[log]);
193 message((-1, "[%d] %s reserve n %I*d offset %I*d", __LINE__, state->logs[log].name, sizeof(n), n, sizeof(con->blocked[log]), con->blocked[log]));
194 if (!(s = sfreserve(state->logs[log].sp, n, 0)))
195 error(ERROR_SYSTEM|3, "%s: cannot reserve %d at %I*d", state->logs[log].name, sizeof(n), n, sizeof(con->blocked[log]), con->blocked[log]);
196 r = note(css, con, log, s, n, 1, disc);
197 if (state->logs[log].sp && sfseek(state->logs[log].sp, state->logs[log].offset, SEEK_SET) != state->logs[log].offset)
198 error(ERROR_SYSTEM|3, "%s: cannot seek to %I*d", state->logs[log].name, sizeof(state->logs[log].offset), state->logs[log].offset);
228 note(css, to, state->log, s, n, 0, disc);
231 note(css, to, state->log, s, n, 0, disc);
351 if ((con->blocked[!state->log] < 0 || dump(css, con, !state->log, disc)) && con->blocked[state->log] >= 0)
352 dump(css, con, state->log, disc);