diff options
Diffstat (limited to 'winpr/libwinpr/utils')
-rw-r--r-- | winpr/libwinpr/utils/cmdline.c | 7 | ||||
-rw-r--r-- | winpr/libwinpr/utils/collections/CountdownEvent.c | 10 | ||||
-rw-r--r-- | winpr/libwinpr/utils/collections/HashTable.c | 3 | ||||
-rw-r--r-- | winpr/libwinpr/utils/collections/PubSub.c | 3 | ||||
-rw-r--r-- | winpr/libwinpr/utils/collections/StreamPool.c | 2 | ||||
-rw-r--r-- | winpr/libwinpr/utils/wlog/PacketMessage.c | 37 |
6 files changed, 24 insertions, 38 deletions
diff --git a/winpr/libwinpr/utils/cmdline.c b/winpr/libwinpr/utils/cmdline.c index 3d93c0a..a524d62 100644 --- a/winpr/libwinpr/utils/cmdline.c +++ b/winpr/libwinpr/utils/cmdline.c @@ -515,13 +515,6 @@ static size_t get_element_count(const char* list, BOOL* failed, BOOL fullquoted) if (!fullquoted) { int now = is_quoted(*it); - if ((quoted == 0) && !first) - { - WLog_ERR(TAG, "Invalid argument (misplaced quote) '%s'", list); - *failed = TRUE; - return 0; - } - if (now == quoted) quoted = 0; else if (quoted == 0) diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c index fd23e0c..771ba54 100644 --- a/winpr/libwinpr/utils/collections/CountdownEvent.c +++ b/winpr/libwinpr/utils/collections/CountdownEvent.c @@ -48,7 +48,10 @@ struct CountdownEvent size_t CountdownEvent_CurrentCount(wCountdownEvent* countdown) { WINPR_ASSERT(countdown); - return countdown->count; + EnterCriticalSection(&countdown->lock); + const size_t rc = countdown->count; + LeaveCriticalSection(&countdown->lock); + return rc; } /** @@ -58,7 +61,10 @@ size_t CountdownEvent_CurrentCount(wCountdownEvent* countdown) size_t CountdownEvent_InitialCount(wCountdownEvent* countdown) { WINPR_ASSERT(countdown); - return countdown->initialCount; + EnterCriticalSection(&countdown->lock); + const size_t rc = countdown->initialCount; + LeaveCriticalSection(&countdown->lock); + return rc; } /** diff --git a/winpr/libwinpr/utils/collections/HashTable.c b/winpr/libwinpr/utils/collections/HashTable.c index 7782b2b..8bbaf84 100644 --- a/winpr/libwinpr/utils/collections/HashTable.c +++ b/winpr/libwinpr/utils/collections/HashTable.c @@ -561,7 +561,8 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys) iKey = 0; count = table->numOfElements; - *ppKeys = NULL; + if (ppKeys) + *ppKeys = NULL; if (count < 1) { diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c index 0efffb7..b95f26d 100644 --- a/winpr/libwinpr/utils/collections/PubSub.c +++ b/winpr/libwinpr/utils/collections/PubSub.c @@ -102,7 +102,7 @@ void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count) new_size = pubSub->size * 2; new_event = (wEventType*)realloc(pubSub->events, new_size * sizeof(wEventType)); if (!new_event) - return; + goto fail; pubSub->size = new_size; pubSub->events = new_event; } @@ -110,6 +110,7 @@ void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count) CopyMemory(&pubSub->events[pubSub->count], events, count * sizeof(wEventType)); pubSub->count += count; +fail: if (pubSub->synchronized) PubSub_Unlock(pubSub); } diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index 910309f..3ff113a 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -211,7 +211,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) if (!s) goto out_fail; } - else + else if (s) { Stream_SetPosition(s, 0); Stream_SetLength(s, Stream_Capacity(s)); diff --git a/winpr/libwinpr/utils/wlog/PacketMessage.c b/winpr/libwinpr/utils/wlog/PacketMessage.c index cc1c812..17df1ec 100644 --- a/winpr/libwinpr/utils/wlog/PacketMessage.c +++ b/winpr/libwinpr/utils/wlog/PacketMessage.c @@ -29,27 +29,11 @@ #include <winpr/crt.h> #include <winpr/file.h> #include <winpr/stream.h> +#include <winpr/sysinfo.h> #include "../../log.h" #define TAG WINPR_TAG("utils.wlog") -#ifndef _WIN32 -#include <sys/time.h> -#else -#include <time.h> -#include <sys/timeb.h> -#include <winpr/windows.h> - -static int gettimeofday(struct timeval* tp, void* tz) -{ - struct _timeb timebuffer; - _ftime(&timebuffer); - tp->tv_sec = (long)timebuffer.time; - tp->tv_usec = timebuffer.millitm * 1000; - return 0; -} -#endif - static BOOL Pcap_Read_Header(wPcap* pcap, wPcapHeader* header) { if (pcap && pcap->fp && fread((void*)header, sizeof(wPcapHeader), 1, pcap->fp) == 1) @@ -89,8 +73,7 @@ static BOOL Pcap_Read_Record(wPcap* pcap, wPcapRecord* record) static BOOL Pcap_Add_Record(wPcap* pcap, void* data, UINT32 length) { - wPcapRecord* record; - struct timeval tp; + wPcapRecord* record = NULL; if (!pcap->tail) { @@ -117,9 +100,10 @@ static BOOL Pcap_Add_Record(wPcap* pcap, void* data, UINT32 length) record->length = length; record->header.incl_len = length; record->header.orig_len = length; - gettimeofday(&tp, 0); - record->header.ts_sec = tp.tv_sec; - record->header.ts_usec = tp.tv_usec; + + UINT64 ns = winpr_GetUnixTimeNS(); + record->header.ts_sec = WINPR_TIME_NS_TO_S(ns); + record->header.ts_usec = WINPR_TIME_NS_REM_US(ns); return TRUE; } @@ -380,7 +364,6 @@ BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flag { wTcpHeader tcp; wIPv4Header ipv4; - struct timeval tp; wPcapRecord record; wEthernetHeader ethernet; ethernet.Type = 0x0800; @@ -474,9 +457,11 @@ BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flag record.header.incl_len = (UINT32)record.length + offset; record.header.orig_len = (UINT32)record.length + offset; record.next = NULL; - gettimeofday(&tp, 0); - record.header.ts_sec = tp.tv_sec; - record.header.ts_usec = tp.tv_usec; + + UINT64 ns = winpr_GetUnixTimeNS(); + record.header.ts_sec = WINPR_TIME_NS_TO_S(ns); + record.header.ts_usec = WINPR_TIME_NS_REM_US(ns); + if (!Pcap_Write_RecordHeader(pcap, &record.header) || !WLog_PacketMessage_Write_EthernetHeader(pcap, ðernet) || !WLog_PacketMessage_Write_IPv4Header(pcap, &ipv4) || |