void moloch_session_get_tag_cb(void *sessionV, int tagType, const char *tagName, uint32_t tag, gboolean async) { MolochSession_t *session = sessionV; if (tag == 0) { LOG("ERROR - Not adding tag %s type %d couldn't get tag num", tagName, tagType); moloch_session_decr_outstanding(session); } else if (async) { moloch_session_add_cmd(session, MOLOCH_SES_CMD_ADD_TAG, (gpointer)(long)tagType, (gpointer)(long)tag, NULL); } else { moloch_field_int_add(tagType, session, tag); moloch_session_decr_outstanding(session); } }
void wise_session_cmd_cb(MolochSession_t *session, gpointer uw1, gpointer UNUSED(uw2)) { WiseItem_t *wi = uw1; if (wi) { wise_process_ops(session, wi); } moloch_session_decr_outstanding(session); }
static int MS_decr_outstanding(lua_State *L) { if (lua_gettop(L) != 1 || !lua_isuserdata(L, 1)) { return luaL_error(L, "usage: <session>"); } MolochSession_t *session = checkMolochSession(L, 1); moloch_session_decr_outstanding(session); return 0; }
void moloch_session_process_commands(int thread) { // Commands MolochSesCmd_t *cmd = 0; int count; for (count = 0; count < 50; count++) { MOLOCH_LOCK(sessionCmds[thread].lock); DLL_POP_HEAD(cmd_, &sessionCmds[thread], cmd); MOLOCH_UNLOCK(sessionCmds[thread].lock); if (!cmd) break; switch (cmd->cmd) { case MOLOCH_SES_CMD_ADD_TAG: moloch_field_int_add((long)cmd->uw1, cmd->session, (long)cmd->uw2); moloch_session_decr_outstanding(cmd->session); break; case MOLOCH_SES_CMD_FUNC: cmd->func(cmd->session, cmd->uw1, cmd->uw2); break; default: LOG ("Unknown cmd %d", cmd->cmd); } MOLOCH_TYPE_FREE(MolochSesCmd_t, cmd); } // Closing Q for (count = 0; count < 10; count++) { MolochSession_t *session = DLL_PEEK_HEAD(q_, &closingQ[thread]); if (session && session->saveTime < (uint64_t)lastPacketSecs[thread]) { moloch_session_save(session); } else { break; } } // Sessions Idle Long Time int ses; for (ses = 0; ses < SESSION_MAX; ses++) { for (count = 0; count < 10; count++) { MolochSession_t *session = DLL_PEEK_HEAD(q_, &sessionsQ[thread][ses]); if (session && (DLL_COUNT(q_, &sessionsQ[thread][ses]) > (int)config.maxStreams || ((uint64_t)session->lastPacket.tv_sec + config.timeouts[ses] < (uint64_t)lastPacketSecs[thread]))) { moloch_session_save(session); } else { break; } } } // TCP Sessions Open Long Time for (count = 0; count < 50; count++) { MolochSession_t *session = DLL_PEEK_HEAD(tcp_, &tcpWriteQ[thread]); if (session && (uint64_t)session->saveTime < (uint64_t)lastPacketSecs[thread]) { moloch_session_mid_save(session, lastPacketSecs[thread]); } else { break; } } }