diff options
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r-- | src/util/common_logging.c | 75 |
1 files changed, 3 insertions, 72 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 4c7a5291f..7a2d5a0b5 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -241,13 +241,6 @@ static int gnunet_force_log_parsed; | |||
241 | static int gnunet_force_log_present; | 241 | static int gnunet_force_log_present; |
242 | #endif | 242 | #endif |
243 | 243 | ||
244 | #ifdef WINDOWS | ||
245 | /** | ||
246 | * Contains the number of performance counts per second. | ||
247 | */ | ||
248 | static LARGE_INTEGER performance_frequency; | ||
249 | #endif | ||
250 | |||
251 | 244 | ||
252 | /** | 245 | /** |
253 | * Convert a textual description of a loglevel | 246 | * Convert a textual description of a loglevel |
@@ -283,9 +276,6 @@ get_type(const char *log) | |||
283 | void | 276 | void |
284 | GNUNET_abort_() | 277 | GNUNET_abort_() |
285 | { | 278 | { |
286 | #if WINDOWS | ||
287 | DebugBreak(); | ||
288 | #endif | ||
289 | abort(); | 279 | abort(); |
290 | } | 280 | } |
291 | 281 | ||
@@ -377,14 +367,10 @@ setup_log_file(const struct tm *tm) | |||
377 | strerror(errno)); | 367 | strerror(errno)); |
378 | return GNUNET_SYSERR; | 368 | return GNUNET_SYSERR; |
379 | } | 369 | } |
380 | #if WINDOWS | ||
381 | altlog_fd = | ||
382 | open(fn, O_APPEND | O_BINARY | O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE); | ||
383 | #else | ||
384 | altlog_fd = open(fn, | 370 | altlog_fd = open(fn, |
385 | O_APPEND | O_WRONLY | O_CREAT, | 371 | O_APPEND | O_WRONLY | O_CREAT, |
386 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); | 372 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
387 | #endif | 373 | |
388 | if (-1 != altlog_fd) | 374 | if (-1 != altlog_fd) |
389 | { | 375 | { |
390 | if (NULL != GNUNET_stderr) | 376 | if (NULL != GNUNET_stderr) |
@@ -725,9 +711,6 @@ GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile) | |||
725 | #if !defined(GNUNET_CULL_LOGGING) | 711 | #if !defined(GNUNET_CULL_LOGGING) |
726 | parse_all_definitions(); | 712 | parse_all_definitions(); |
727 | #endif | 713 | #endif |
728 | #ifdef WINDOWS | ||
729 | QueryPerformanceFrequency(&performance_frequency); | ||
730 | #endif | ||
731 | GNUNET_free_non_null(component); | 714 | GNUNET_free_non_null(component); |
732 | GNUNET_asprintf(&component, "%s-%d", comp, getpid()); | 715 | GNUNET_asprintf(&component, "%s-%d", comp, getpid()); |
733 | GNUNET_free_non_null(component_nopid); | 716 | GNUNET_free_non_null(component_nopid); |
@@ -809,10 +792,6 @@ GNUNET_logger_remove(GNUNET_Logger logger, void *logger_cls) | |||
809 | GNUNET_free(pos); | 792 | GNUNET_free(pos); |
810 | } | 793 | } |
811 | 794 | ||
812 | #if WINDOWS | ||
813 | CRITICAL_SECTION output_message_cs; | ||
814 | #endif | ||
815 | |||
816 | 795 | ||
817 | /** | 796 | /** |
818 | * Actually output the log message. | 797 | * Actually output the log message. |
@@ -830,9 +809,6 @@ output_message(enum GNUNET_ErrorType kind, | |||
830 | { | 809 | { |
831 | struct CustomLogger *pos; | 810 | struct CustomLogger *pos; |
832 | 811 | ||
833 | #if WINDOWS | ||
834 | EnterCriticalSection(&output_message_cs); | ||
835 | #endif | ||
836 | /* only use the standard logger if no custom loggers are present */ | 812 | /* only use the standard logger if no custom loggers are present */ |
837 | if ((NULL != GNUNET_stderr) && (NULL == loggers)) | 813 | if ((NULL != GNUNET_stderr) && (NULL == loggers)) |
838 | { | 814 | { |
@@ -887,9 +863,6 @@ output_message(enum GNUNET_ErrorType kind, | |||
887 | pos->logger(pos->logger_cls, kind, comp, datestr, msg); | 863 | pos->logger(pos->logger_cls, kind, comp, datestr, msg); |
888 | pos = pos->next; | 864 | pos = pos->next; |
889 | } | 865 | } |
890 | #if WINDOWS | ||
891 | LeaveCriticalSection(&output_message_cs); | ||
892 | #endif | ||
893 | } | 866 | } |
894 | 867 | ||
895 | 868 | ||
@@ -1003,33 +976,7 @@ mylog(enum GNUNET_ErrorType kind, | |||
1003 | { | 976 | { |
1004 | char buf[size]; | 977 | char buf[size]; |
1005 | long long offset; | 978 | long long offset; |
1006 | #ifdef WINDOWS | ||
1007 | LARGE_INTEGER pc; | ||
1008 | time_t timetmp; | ||
1009 | 979 | ||
1010 | offset = GNUNET_TIME_get_offset(); | ||
1011 | time(&timetmp); | ||
1012 | timetmp += offset / 1000; | ||
1013 | tmptr = localtime(&timetmp); | ||
1014 | pc.QuadPart = 0; | ||
1015 | QueryPerformanceCounter(&pc); | ||
1016 | if (NULL == tmptr) | ||
1017 | { | ||
1018 | strcpy(date, "localtime error"); | ||
1019 | } | ||
1020 | else | ||
1021 | { | ||
1022 | if (0 == | ||
1023 | strftime(date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%020llu", tmptr)) | ||
1024 | abort(); | ||
1025 | if (0 > snprintf(date, | ||
1026 | sizeof(date), | ||
1027 | date2, | ||
1028 | (long long)(pc.QuadPart / | ||
1029 | (performance_frequency.QuadPart / 1000)))) | ||
1030 | abort(); | ||
1031 | } | ||
1032 | #else | ||
1033 | struct timeval timeofday; | 980 | struct timeval timeofday; |
1034 | 981 | ||
1035 | gettimeofday(&timeofday, NULL); | 982 | gettimeofday(&timeofday, NULL); |
@@ -1069,7 +1016,7 @@ mylog(enum GNUNET_ErrorType kind, | |||
1069 | if (0 > snprintf(date, sizeof(date), date2, timeofday.tv_usec)) | 1016 | if (0 > snprintf(date, sizeof(date), date2, timeofday.tv_usec)) |
1070 | abort(); | 1017 | abort(); |
1071 | } | 1018 | } |
1072 | #endif | 1019 | |
1073 | vsnprintf(buf, size, message, va); | 1020 | vsnprintf(buf, size, message, va); |
1074 | #if !(defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY) | 1021 | #if !(defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY) |
1075 | if (NULL != tmptr) | 1022 | if (NULL != tmptr) |
@@ -1433,13 +1380,9 @@ GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid) | |||
1433 | const char * | 1380 | const char * |
1434 | GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen) | 1381 | GNUNET_a2s(const struct sockaddr *addr, socklen_t addrlen) |
1435 | { | 1382 | { |
1436 | #ifndef WINDOWS | ||
1437 | #define LEN \ | 1383 | #define LEN \ |
1438 | GNUNET_MAX((INET6_ADDRSTRLEN + 8), \ | 1384 | GNUNET_MAX((INET6_ADDRSTRLEN + 8), \ |
1439 | (1 + sizeof(struct sockaddr_un) - sizeof(sa_family_t))) | 1385 | (1 + sizeof(struct sockaddr_un) - sizeof(sa_family_t))) |
1440 | #else | ||
1441 | #define LEN (INET6_ADDRSTRLEN + 8) | ||
1442 | #endif | ||
1443 | static char buf[LEN]; | 1386 | static char buf[LEN]; |
1444 | #undef LEN | 1387 | #undef LEN |
1445 | static char b2[6]; | 1388 | static char b2[6]; |
@@ -1603,13 +1546,6 @@ GNUNET_async_scope_get(struct GNUNET_AsyncScopeSave *scope_ret) | |||
1603 | void __attribute__ ((constructor)) GNUNET_util_cl_init() | 1546 | void __attribute__ ((constructor)) GNUNET_util_cl_init() |
1604 | { | 1547 | { |
1605 | GNUNET_stderr = stderr; | 1548 | GNUNET_stderr = stderr; |
1606 | #ifdef MINGW | ||
1607 | GNInitWinEnv(NULL); | ||
1608 | #endif | ||
1609 | #if WINDOWS | ||
1610 | if (!InitializeCriticalSectionAndSpinCount(&output_message_cs, 0x00000400)) | ||
1611 | GNUNET_abort_(); | ||
1612 | #endif | ||
1613 | } | 1549 | } |
1614 | 1550 | ||
1615 | 1551 | ||
@@ -1618,12 +1554,7 @@ void __attribute__ ((constructor)) GNUNET_util_cl_init() | |||
1618 | */ | 1554 | */ |
1619 | void __attribute__ ((destructor)) GNUNET_util_cl_fini() | 1555 | void __attribute__ ((destructor)) GNUNET_util_cl_fini() |
1620 | { | 1556 | { |
1621 | #if WINDOWS | 1557 | |
1622 | DeleteCriticalSection(&output_message_cs); | ||
1623 | #endif | ||
1624 | #ifdef MINGW | ||
1625 | GNShutdownWinEnv(); | ||
1626 | #endif | ||
1627 | } | 1558 | } |
1628 | 1559 | ||
1629 | /* end of common_logging.c */ | 1560 | /* end of common_logging.c */ |