Small http.log improvement: bail out early if there is nothing to log. Make output locking more fine grained.

remotes/origin/master
Victor Julien 15 years ago
parent e581ec7dff
commit 9696902b68

@ -209,6 +209,11 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet
}
size_t loggable = (size_t)r;
/* nothing to do */
if (logged >= loggable) {
goto end;
}
HtpState *htp_state = (HtpState *)AppLayerGetProtoStateFromPacket(p);
if (htp_state == NULL) {
SCLogDebug("no http state, so no request logging");
@ -256,7 +261,6 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet
dp = p->sp;
}
SCMutexLock(&hlog->file_ctx->fp_mutex);
for (idx = logged; idx < loggable; idx++)
{
tx = list_get(htp_state->connp->conn->transactions, idx);
@ -265,6 +269,9 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet
continue;
}
/* output now starting, so get output lock */
SCMutexLock(&hlog->file_ctx->fp_mutex);
SCLogDebug("got a HTTP request and now logging !!");
/* time */
fprintf(hlog->file_ctx->fp, "%s ", timebuf);
@ -310,11 +317,11 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet
srcip, sp, dstip, dp);
aft->uri_cnt ++;
fflush(hlog->file_ctx->fp);
SCMutexUnlock(&hlog->file_ctx->fp_mutex);
AppLayerTransactionUpdateLoggedId(p->flow);
}
fflush(hlog->file_ctx->fp);
SCMutexUnlock(&hlog->file_ctx->fp_mutex);
end:
SCMutexUnlock(&p->flow->m);

Loading…
Cancel
Save