Index: pgsql.c =================================================================== --- pgsql.c (revision 972) +++ pgsql.c (working copy) @@ -235,27 +235,17 @@ ipone.s_addr=ntohl((element.tracking_hdrs).saddr); strncpy(tmp_inet1,inet_ntoa(ipone),40) ; if (nuauth_log_users_strict){ - char *my_timestamp; - my_timestamp=(char *)calloc(26,sizeof(char)); - if (my_timestamp == NULL) - { - g_warning("Can not malloc for my_timestamp"); - return -1; - } - epoch_to_char(element.timestamp,&my_timestamp); - if (snprintf(request,SHORT_REQUEST_SIZE-1,"UPDATE %s SET end_timestamp='%s', state=%hu WHERE (ip_saddr='%s' and tcp_sport=%u and (state=1 or state=2))", + if (snprintf(request,SHORT_REQUEST_SIZE-1,"UPDATE %s SET end_timestamp=%u, state=%hu WHERE (ip_saddr='%s' and tcp_sport=%u and (state=1 or state=2))", pgsql_table_name, - my_timestamp, + element.timestamp, STATE_CLOSE, tmp_inet1, (element.tracking_hdrs).source ) >= SHORT_REQUEST_SIZE-1){ if (DEBUG_OR_NOT(DEBUG_LEVEL_SERIOUS_WARNING,DEBUG_AREA_MAIN)) g_warning("Building pgsql update query, the SHORT_REQUEST_SIZE limit was reached!\n"); - free(my_timestamp); return -1; } - free(my_timestamp); Result = PQexec(ld, request); if (!Result == PGRES_TUPLES_OK){ if (DEBUG_OR_NOT(DEBUG_LEVEL_SERIOUS_WARNING,DEBUG_AREA_MAIN)) @@ -407,23 +397,15 @@ if ((element.tracking_hdrs).protocol == IPPROTO_TCP){ int update_status = 0; while (update_status < 2){ - char *my_timestamp; - my_timestamp=(char *)calloc(26,sizeof(char)); - if (my_timestamp == NULL) - { - g_warning("Can not malloc for my_timestamp"); - return -1; - } - epoch_to_char(element.timestamp,&my_timestamp); update_status++; ipone.s_addr=ntohl((element.tracking_hdrs).saddr); iptwo.s_addr=ntohl((element.tracking_hdrs).daddr); strncpy(tmp_inet1,inet_ntoa(ipone),40) ; strncpy(tmp_inet2,inet_ntoa(iptwo),40) ; - if (snprintf(request,SHORT_REQUEST_SIZE-1,"UPDATE %s SET state=%hu, start_timestamp='%s' WHERE (ip_daddr='%s' and ip_saddr='%s' and tcp_dport=%u and tcp_sport=%u and state=%hu);", + if (snprintf(request,SHORT_REQUEST_SIZE-1,"UPDATE %s SET state=%hu, start_timestamp=%u WHERE (ip_daddr='%s' and ip_saddr='%s' and tcp_dport=%u and tcp_sport=%u and state=%hu);", pgsql_table_name, STATE_ESTABLISHED, - my_timestamp, + element.timestamp, tmp_inet1, tmp_inet2, (element.tracking_hdrs).source, @@ -432,10 +414,8 @@ ) >= SHORT_REQUEST_SIZE-1){ if (DEBUG_OR_NOT(DEBUG_LEVEL_SERIOUS_WARNING,DEBUG_AREA_MAIN)) g_warning("Building pgsql update query, the SHORT_REQUEST_SIZE limit was reached!\n"); - free(my_timestamp); return -1; } - free(my_timestamp); Result = PQexec(ld, request); if (!Result == PGRES_TUPLES_OK){ if (DEBUG_OR_NOT(DEBUG_LEVEL_SERIOUS_WARNING,DEBUG_AREA_MAIN)) @@ -463,14 +443,6 @@ if ((element.tracking_hdrs).protocol == IPPROTO_TCP){ int update_status = 0; while (update_status < 2){ - char *my_timestamp; - my_timestamp=(char *)calloc(26,sizeof(char)); - if (my_timestamp == NULL) - { - g_warning("Can not malloc for my_timestamp"); - return -1; - } - epoch_to_char(element.timestamp,&my_timestamp); update_status++; ipone.s_addr=ntohl((element.tracking_hdrs).saddr); iptwo.s_addr=ntohl((element.tracking_hdrs).daddr); @@ -478,7 +450,7 @@ strncpy(tmp_inet2,inet_ntoa(iptwo),40) ; if (snprintf(request,SHORT_REQUEST_SIZE-1,"UPDATE %s SET end_timestamp='%s', state=%hu WHERE (ip_saddr='%s' and ip_daddr='%s' and tcp_sport=%u and tcp_dport=%u and state=%hu);", pgsql_table_name, - my_timestamp, + element.timestamp, STATE_CLOSE, tmp_inet1, tmp_inet2, @@ -488,10 +460,8 @@ ) >= SHORT_REQUEST_SIZE-1){ if (DEBUG_OR_NOT(DEBUG_LEVEL_SERIOUS_WARNING,DEBUG_AREA_MAIN)) g_warning("Building pgsql update query, the SHORT_REQUEST_SIZE limit was reached!\n"); - free(my_timestamp); return -1; } - free(my_timestamp); Result = PQexec(ld, request); if (!Result == PGRES_TUPLES_OK){ if (DEBUG_OR_NOT(DEBUG_LEVEL_SERIOUS_WARNING,DEBUG_AREA_MAIN))