Skip to content

Commit 084b21e

Browse files
committed
common/wincompat.c: log errors after methods faults via upslog_with_errno() not plain upslogx() [#3302]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent b617936 commit 084b21e

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

common/wincompat.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ void pipe_create(const char * pipe_name)
568568
/* Wait for a connection */
569569
ret = ConnectNamedPipe(pipe_connection_handle, &pipe_connection_overlapped);
570570
if (ret == 0 && GetLastError() != ERROR_IO_PENDING) {
571-
upslogx(LOG_ERR, "ConnectNamedPipe error");
571+
upslog_with_errno(LOG_ERR, "ConnectNamedPipe error");
572572
}
573573
}
574574

@@ -601,7 +601,7 @@ void pipe_connect()
601601
);
602602
if (conn->overlapped.hEvent == NULL) {
603603
/* FIXME: Is this (still) about event log only? */
604-
upslogx(LOG_ERR, "Can't create event for reading event log");
604+
upslog_with_errno(LOG_ERR, "Can't create event for reading event log");
605605
return;
606606
}
607607

@@ -630,9 +630,7 @@ void pipe_disconnect(pipe_conn_t *conn)
630630
if (conn->handle != INVALID_HANDLE_VALUE) {
631631
upsdebugx(4, "%s: calling DisconnectNamedPipe() for not-yet-invalid conn->handle", __func__);
632632
if (DisconnectNamedPipe(conn->handle) == 0) {
633-
upslogx(LOG_ERR,
634-
"DisconnectNamedPipe error : %d",
635-
(int)GetLastError());
633+
upslog_with_errno(LOG_ERR, "DisconnectNamedPipe failed");
636634
}
637635
upsdebugx(4, "%s: calling CloseHandle() for conn->handle", __func__);
638636
CloseHandle(conn->handle);
@@ -661,7 +659,7 @@ int pipe_ready(pipe_conn_t *conn)
661659

662660
res = GetOverlappedResult(conn->handle, &conn->overlapped, &bytesRead, FALSE);
663661
if (res == 0) {
664-
upslogx(LOG_ERR, "Pipe read error");
662+
upslog_with_errno(LOG_ERR, "Pipe read error");
665663
pipe_disconnect(conn);
666664
return 0;
667665
}
@@ -698,6 +696,7 @@ int send_to_named_pipe(const char * pipe_name, const char * data)
698696
result = WriteFile(pipe, data, len + 1, &bytesWritten, NULL);
699697

700698
if (result == 0 || bytesWritten != len + 1) {
699+
upsdebug_with_errno(6, "%s: closing event log NAMED_PIPE, did not write as much as expected to", __func__);
701700
CloseHandle(pipe);
702701
return 1;
703702
}
@@ -978,7 +977,7 @@ serial_handler_t * w32_serial_open(const char *name, int flags)
978977
0);
979978

980979
if (sh->handle == INVALID_HANDLE_VALUE) {
981-
upslogx(LOG_ERR, "could not open %s", name);
980+
upslog_with_errno(LOG_ERR, "could not open %s", name);
982981
errno = EPERM;
983982
return NULL;
984983
}
@@ -1017,7 +1016,7 @@ serial_handler_t * w32_serial_open(const char *name, int flags)
10171016
state.fAbortOnError = TRUE;
10181017

10191018
if (!SetCommState(sh->handle, &state)) {
1020-
upslogx(LOG_ERR,
1019+
upslog_with_errno(LOG_ERR,
10211020
"couldn't set initial state for %s",
10221021
name);
10231022
}
@@ -1492,7 +1491,7 @@ TCSAFLUSH: flush output and discard input, then change attributes.
14921491
res = SetCommTimeouts(sh->handle, &to);
14931492
if (!res)
14941493
{
1495-
upslogx(LOG_ERR, "SetCommTimeout failed");
1494+
upslog_with_errno(LOG_ERR, "SetCommTimeout failed");
14961495
errno = EIO;
14971496
return -1;
14981497
}

0 commit comments

Comments
 (0)