Skip to content

Commit

Permalink
refactor(arch): Remove the duplicity of UA_AGAIN, UA_EAGAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfr committed Dec 27, 2021
1 parent 09a1927 commit b20fcfe
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
3 changes: 1 addition & 2 deletions arch/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ To port to a new architecture you should follow these steps:
//#define UA_IPV6 1 //or 0
//#define UA_SOCKET
//#define UA_INVALID_SOCKET
//#define UA_ERRNO
//#define UA_ERRNO
//#define UA_INTERRUPTED
//#define UA_AGAIN
//#define UA_EAGAIN
//#define UA_WOULDBLOCK
//#define UA_INTERRUPTED

Expand Down
3 changes: 1 addition & 2 deletions arch/common/ua_lwip.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
#define UA_INVALID_SOCKET -1
#define UA_ERRNO errno
#define UA_INTERRUPTED EINTR
#define UA_AGAIN EAGAIN
#define UA_EAGAIN EAGAIN
#define UA_AGAIN EAGAIN /* the same as wouldblock on nearly every system */
#define UA_WOULDBLOCK EWOULDBLOCK

#define UA_send lwip_send
Expand Down
3 changes: 1 addition & 2 deletions arch/eCos/ua_architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
#define UA_INVALID_SOCKET -1
#define UA_ERRNO errno
#define UA_INTERRUPTED EINTR
#define UA_AGAIN EAGAIN
#define UA_EAGAIN EAGAIN
#define UA_AGAIN EAGAIN /* the same as wouldblock on nearly every system */
#define UA_WOULDBLOCK EWOULDBLOCK

#define UA_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) \
Expand Down
9 changes: 7 additions & 2 deletions arch/eventloop_posix_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ TCP_connectionSocketCallback(UA_ConnectionManager *cm, UA_FD fd,
response.length = (size_t)ret; /* Set the length of the received buffer */
cm->connectionCallback(cm, (uintptr_t)fd, fdcontext,
UA_STATUSCODE_GOOD, 0, NULL, response);
} else if(UA_ERRNO != UA_INTERRUPTED && UA_ERRNO != UA_EAGAIN) {
} else if(UA_ERRNO != UA_INTERRUPTED &&
UA_ERRNO != UA_WOULDBLOCK &&
UA_ERRNO != UA_AGAIN) {
/* Orderly shutdown of the connection. Signal to the application and
* then close the connection. We end up in this path after shutdown was
* called on the socket. Here, we then are in the next EventLoop
Expand Down Expand Up @@ -489,7 +491,10 @@ TCP_sendWithConnection(UA_ConnectionManager *cm, uintptr_t connectionId,
n = UA_send((UA_FD)connectionId,
(const char*)buf->data + nWritten,
bytes_to_send, flags);
if(n < 0 && UA_ERRNO != UA_INTERRUPTED && UA_ERRNO != UA_AGAIN) {
if(n < 0 &&
UA_ERRNO != UA_INTERRUPTED &&
UA_ERRNO != UA_WOULDBLOCK &&
UA_ERRNO != UA_AGAIN) {
UA_LOG_SOCKET_ERRNO_GAI_WRAP(
UA_LOG_ERROR(UA_EventLoop_getLogger(cm->eventSource.eventLoop),
UA_LOGCATEGORY_NETWORK,
Expand Down
2 changes: 1 addition & 1 deletion arch/network_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ connection_recv(UA_Connection *connection, UA_ByteString *response,
if(internallyAllocated)
UA_ByteString_clear(response);
if(UA_ERRNO == UA_INTERRUPTED || (timeout > 0) ?
false : (UA_ERRNO == UA_EAGAIN || UA_ERRNO == UA_WOULDBLOCK))
false : (UA_ERRNO == UA_AGAIN || UA_ERRNO == UA_WOULDBLOCK))
return UA_STATUSCODE_GOOD; /* statuscode_good but no data -> retry */
connection->close(connection);
return UA_STATUSCODE_BADCONNECTIONCLOSED;
Expand Down
3 changes: 1 addition & 2 deletions arch/posix/ua_architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ void UA_sleep_ms(unsigned long ms);
#define UA_INVALID_SOCKET -1
#define UA_ERRNO errno
#define UA_INTERRUPTED EINTR
#define UA_AGAIN EAGAIN
#define UA_EAGAIN EAGAIN
#define UA_AGAIN EAGAIN /* the same as wouldblock on nearly every system */
#define UA_WOULDBLOCK EWOULDBLOCK

#define UA_POLLIN POLLIN
Expand Down
3 changes: 1 addition & 2 deletions arch/vxworks/ua_architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
#define UA_INVALID_SOCKET -1
#define UA_ERRNO errno
#define UA_INTERRUPTED EINTR
#define UA_AGAIN EAGAIN
#define UA_EAGAIN EAGAIN
#define UA_AGAIN EAGAIN /* the same as wouldblock on nearly every system */
#define UA_WOULDBLOCK EWOULDBLOCK

#define UA_ENABLE_LOG_COLORS
Expand Down
3 changes: 1 addition & 2 deletions arch/wec7/ua_architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void UA_sleep_ms(unsigned long ms);
#endif
#define UA_ERRNO WSAGetLastError()
#define UA_INTERRUPTED WSAEINTR
#define UA_AGAIN WSAEWOULDBLOCK
#define UA_EAGAIN EAGAIN
#define UA_AGAIN EAGAIN /* the same as wouldblock on nearly every system */
#define UA_WOULDBLOCK WSAEWOULDBLOCK

#define UA_fd_set(fd, fds) FD_SET((UA_SOCKET)fd, fds)
Expand Down
3 changes: 1 addition & 2 deletions arch/win32/ua_architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ void UA_sleep_ms(unsigned long ms);
#define UA_INVALID_SOCKET INVALID_SOCKET
#define UA_ERRNO WSAGetLastError()
#define UA_INTERRUPTED WSAEINTR
#define UA_AGAIN WSAEWOULDBLOCK
#define UA_EAGAIN EAGAIN
#define UA_AGAIN EAGAIN /* the same as wouldblock on nearly every system */
#define UA_WOULDBLOCK WSAEWOULDBLOCK
#define UA_POLLIN POLLRDNORM
#define UA_POLLOUT POLLWRNORM
Expand Down

0 comments on commit b20fcfe

Please sign in to comment.