Change-Id: I6febe51c093f2aed9fb1c78adeff435e009a8a8c
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4794
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Kumar Kaushik <kaushikk@vmware.com>
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
Name: c-rest-engine |
2 | 2 |
Summary: minimal http(s) server library |
3 |
-Version: 1.1 |
|
3 |
+Version: 1.2 |
|
4 | 4 |
Release: 1%{?dist} |
5 | 5 |
Group: Applications/System |
6 | 6 |
Vendor: VMware, Inc. |
... | ... |
@@ -11,13 +11,8 @@ Requires: openssl >= 1.0.1 |
11 | 11 |
BuildRequires: coreutils >= 8.22 |
12 | 12 |
BuildRequires: openssl-devel >= 1.0.1 |
13 | 13 |
Source0: %{name}-%{version}.tar.gz |
14 |
-Patch1: socket_RW.patch |
|
15 |
-Patch2: syslog_noInit.patch |
|
16 |
-Patch3: socket_logging.patch |
|
17 |
-Patch4: c-rest-engine-fix-log-file-len.patch |
|
18 |
-Patch5: errno_init.patch |
|
19 |
-Patch6: ssl_shutdown.patch |
|
20 |
-%define sha1 c-rest-engine=a25927fd98ec92df5e210cc4941fa626604636f6 |
|
14 |
+Patch1: c-rest-engine-fix-log-file-len.patch |
|
15 |
+%define sha1 c-rest-engine=25aa9d1f2680e26114dee18365c510692552f8e4 |
|
21 | 16 |
|
22 | 17 |
%description |
23 | 18 |
c-rest-engine is a minimal embedded http(s) server written in C. |
... | ... |
@@ -35,11 +30,6 @@ development libs and header files for c-rest-engine |
35 | 35 |
%prep |
36 | 36 |
%setup -q |
37 | 37 |
%patch1 -p1 |
38 |
-%patch2 -p1 |
|
39 |
-%patch3 -p1 |
|
40 |
-%patch4 -p1 |
|
41 |
-%patch5 -p1 |
|
42 |
-%patch6 -p1 |
|
43 | 38 |
|
44 | 39 |
%build |
45 | 40 |
cd build |
... | ... |
@@ -72,6 +62,8 @@ find %{buildroot} -name '*.la' -delete |
72 | 72 |
# %doc ChangeLog README COPYING |
73 | 73 |
|
74 | 74 |
%changelog |
75 |
+* Wed Feb 14 2018 Kumar Kaushik <kaushikk@vmware.com> 1.2-1 |
|
76 |
+- Upgrading to version 1.2. Removing all upstream patches. |
|
75 | 77 |
* Thu Nov 23 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.1-1 |
76 | 78 |
- Update to v1.1-1 |
77 | 79 |
* Thu Nov 02 2017 Kumar Kaushik <kaushikk@vmware.com> 1.0.5-1 |
78 | 80 |
deleted file mode 100644 |
... | ... |
@@ -1,111 +0,0 @@ |
1 |
-From b9a3185e4556e8c5785a60fb57c2924bbd0529f7 Mon Sep 17 00:00:00 2001 |
|
2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
3 |
-Date: Wed, 29 Nov 2017 18:47:39 -0800 |
|
4 |
-Subject: [PATCH] Avoiding previous errno variable use |
|
5 |
- |
|
6 |
-Change-Id: I76b0ef967df8b1ad6fa1844e1e461af470bb3b0f |
|
7 |
- transport/posix/socket.c | 51 +++++++++++++++++++++++++++++++----------------- |
|
8 |
- 1 file changed, 33 insertions(+), 18 deletions(-) |
|
9 |
- |
|
10 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
11 |
-index 79c7a38..d3a3dbc 100644 |
|
12 |
-+++ b/transport/posix/socket.c |
|
13 |
-@@ -853,6 +853,8 @@ VmSockPosixRead( |
|
14 |
- do |
|
15 |
- { |
|
16 |
- nRead = 0; |
|
17 |
-+ errno = 0; |
|
18 |
-+ errorCode = 0; |
|
19 |
- if (pRESTHandle->pSSLInfo->isSecure && (pSocket->ssl != NULL)) |
|
20 |
- { |
|
21 |
- nRead = SSL_read(pSocket->ssl, (pszBufPrev + nPrevBuf), MAX_DATA_BUFFER_LEN); |
|
22 |
-@@ -864,7 +866,7 @@ VmSockPosixRead( |
|
23 |
- errorCode = errno; |
|
24 |
- } |
|
25 |
- |
|
26 |
-- if ((nRead > 0) && (nRead <= MAX_DATA_BUFFER_LEN)) |
|
27 |
-+ if (nRead > 0) |
|
28 |
- { |
|
29 |
- nPrevBuf += nRead; |
|
30 |
- dwError = VmRESTReallocateMemory( |
|
31 |
-@@ -877,22 +879,6 @@ VmSockPosixRead( |
|
32 |
- } |
|
33 |
- }while((nRead > 0) && (nPrevBuf < pRESTHandle->pRESTConfig->maxDataPerConnMB)); |
|
34 |
- |
|
35 |
-- if (((pSocket->fd > 0) && (errorCode == EAGAIN || errorCode == EWOULDBLOCK)) || ((pRESTHandle->pSSLInfo->isSecure) && (errorCode == SSL_ERROR_WANT_READ))) |
|
36 |
-- { |
|
37 |
-- dwError = REST_ENGINE_SUCCESS; |
|
38 |
-- } |
|
39 |
-- else if (nRead < 0) |
|
40 |
-- { |
|
41 |
-- VMREST_LOG_ERROR(pRESTHandle, "Socket read failed with error code %u", errorCode); |
|
42 |
-- dwError = errorCode; |
|
43 |
-- } |
|
44 |
-- else if (nRead == 0) |
|
45 |
-- { |
|
46 |
-- VMREST_LOG_ERROR(pRESTHandle,"%s", "Socket read failed due to broken pipe"); |
|
47 |
-- dwError = VM_SOCK_POSIX_ERROR_BROKEN_PIPE; |
|
48 |
-- } |
|
49 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
50 |
-- |
|
51 |
- if (nPrevBuf >= pRESTHandle->pRESTConfig->maxDataPerConnMB) |
|
52 |
- { |
|
53 |
- /**** Discard the request here itself. This might be the first read IO cycle ****/ |
|
54 |
-@@ -901,6 +887,33 @@ VmSockPosixRead( |
|
55 |
- } |
|
56 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
57 |
- |
|
58 |
-+ if (nRead == -1) |
|
59 |
-+ { |
|
60 |
-+ if (((pSocket->fd > 0) && (errorCode == EAGAIN || errorCode == EWOULDBLOCK)) || ((pRESTHandle->pSSLInfo->isSecure) && (errorCode == SSL_ERROR_WANT_READ))) |
|
61 |
-+ { |
|
62 |
-+ dwError = REST_ENGINE_SUCCESS; |
|
63 |
-+ } |
|
64 |
-+ else |
|
65 |
-+ { |
|
66 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Unknown socket read error: errno %u, errorCode %u, nRead %d", errno, errorCode, nRead); |
|
67 |
-+ dwError = REST_ENGINE_FAILURE; |
|
68 |
-+ } |
|
69 |
-+ } |
|
70 |
-+ else |
|
71 |
-+ { |
|
72 |
-+ if (nRead == 0) |
|
73 |
-+ { |
|
74 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Socket Read Failed: Remote has closed the connection"); |
|
75 |
-+ dwError = VM_SOCK_POSIX_ERROR_BROKEN_PIPE; |
|
76 |
-+ } |
|
77 |
-+ else |
|
78 |
-+ { |
|
79 |
-+ VMREST_LOG_ERROR(pRESTHandle, "Socket read failed with error code %u", errorCode); |
|
80 |
-+ dwError = errorCode; |
|
81 |
-+ } |
|
82 |
-+ } |
|
83 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
84 |
-+ |
|
85 |
- pSocket->pszBuffer = pszBufPrev; |
|
86 |
- pSocket->nProcessed = 0; |
|
87 |
- pSocket->nBufData = nPrevBuf; |
|
88 |
-@@ -933,11 +946,12 @@ VmSockPosixRead( |
|
89 |
- if (pszBufPrev && pSocket && pRESTHandle->pSockContext) |
|
90 |
- { |
|
91 |
- /**** Delete the socket from poller ****/ |
|
92 |
-+ |
|
93 |
- VmSockPosixEventQueueDelete_inlock( |
|
94 |
- pRESTHandle->pSockContext->pEventQueue, |
|
95 |
- pSocket |
|
96 |
- ); |
|
97 |
-- |
|
98 |
-+ |
|
99 |
- VmRESTFreeMemory(pszBufPrev); |
|
100 |
- pszBufPrev = NULL; |
|
101 |
- pSocket->pszBuffer = NULL; |
|
102 |
-@@ -1566,6 +1580,7 @@ VmSockPosixSetRequestHandle( |
|
103 |
- pSocket |
|
104 |
- ); |
|
105 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
106 |
-+ |
|
107 |
- |
|
108 |
- if (pSocket->pTimerSocket->fd > 0) |
|
109 |
- { |
110 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,54 +0,0 @@ |
1 |
-diff -ru c-rest-engine-1.1/transport/posix/defines.h c-rest-engine-1.1-modified/transport/posix/defines.h |
|
2 |
-+++ c-rest-engine-1.1-modified/transport/posix/defines.h 2017-11-10 15:56:01.170279430 -0800 |
|
3 |
-@@ -50,6 +50,7 @@ |
|
4 |
- |
|
5 |
- /**** Transport internal error codes ****/ |
|
6 |
- #define VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED 5100 |
|
7 |
-+#define VM_SOCK_POSIX_ERROR_BROKEN_PIPE 5101 |
|
8 |
- #define MAX_RETRY_ATTEMPTS 50000 |
|
9 |
- |
|
10 |
- |
|
11 |
-diff -ru c-rest-engine-1.1/transport/posix/socket.c c-rest-engine-1.1-modified/transport/posix/socket.c |
|
12 |
-+++ c-rest-engine-1.1-modified/transport/posix/socket.c 2017-11-10 15:55:25.410277664 -0800 |
|
13 |
-@@ -879,10 +879,16 @@ |
|
14 |
- { |
|
15 |
- dwError = REST_ENGINE_SUCCESS; |
|
16 |
- } |
|
17 |
-- else |
|
18 |
-+ else if (nRead < 0) |
|
19 |
- { |
|
20 |
-+ VMREST_LOG_ERROR(pRESTHandle, "Socket read failed with error code %u", errorCode); |
|
21 |
- dwError = errorCode; |
|
22 |
- } |
|
23 |
-+ else if (nRead == 0) |
|
24 |
-+ { |
|
25 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s", "Socket read failed due to broken pipe"); |
|
26 |
-+ dwError = VM_SOCK_POSIX_ERROR_BROKEN_PIPE; |
|
27 |
-+ } |
|
28 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
29 |
- |
|
30 |
- if (nPrevBuf >= pRESTHandle->pRESTConfig->maxDataPerConnMB) |
|
31 |
-@@ -980,7 +986,7 @@ |
|
32 |
- nWritten = write(pSocket->fd, (pszBuffer + nWrittenTotal) ,nRemaining); |
|
33 |
- errorCode = errno; |
|
34 |
- } |
|
35 |
-- if (nWritten >= 0) |
|
36 |
-+ if (nWritten > 0) |
|
37 |
- { |
|
38 |
- nWrittenTotal += nWritten; |
|
39 |
- nRemaining -= nWritten; |
|
40 |
-@@ -1017,6 +1023,12 @@ |
|
41 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
42 |
- } |
|
43 |
- } |
|
44 |
-+ else |
|
45 |
-+ { |
|
46 |
-+ dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
47 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Socket write failed with error code %u, dwError %u, nWritten %d", errorCode, dwError, nWritten); |
|
48 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
49 |
-+ } |
|
50 |
- } |
|
51 |
- } |
|
52 |
- VMREST_LOG_DEBUG(pRESTHandle,"\nWrite Status on Socket with fd = %d\nRequested: %d nBufLen\nWritten %d bytes\n", pSocket->fd, nBufLen, nWrittenTotal); |
53 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,94 +0,0 @@ |
1 |
-From 8afe888fb34b1d121bae7701c51d0e7d0c96cbb5 Mon Sep 17 00:00:00 2001 |
|
2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
3 |
-Date: Mon, 20 Nov 2017 15:21:56 -0800 |
|
4 |
-Subject: [PATCH] Adding more debug for socket read failures |
|
5 |
- |
|
6 |
-Change-Id: I85b10413b4fe9273a11e46da038aa2e31ffd0318 |
|
7 |
-(cherry picked from commit a0c4357aca99a08a28d10875aff87c6e3d1798be) |
|
8 |
- common/sockinterface.c | 11 +++++------ |
|
9 |
- transport/posix/socket.c | 27 ++++++++++++++++++++++++++- |
|
10 |
- 2 files changed, 31 insertions(+), 7 deletions(-) |
|
11 |
- |
|
12 |
-diff --git a/common/sockinterface.c b/common/sockinterface.c |
|
13 |
-index a53c4a5..403189c 100644 |
|
14 |
-+++ b/common/sockinterface.c |
|
15 |
-@@ -521,11 +521,10 @@ VmRESTTcpReceiveNewData( |
|
16 |
- { |
|
17 |
- VMREST_LOG_DEBUG(pRESTHandle,"%s","Calling closed connection...."); |
|
18 |
- /**** Close connection ****/ |
|
19 |
-- dwError = VmRESTDisconnectClient( |
|
20 |
-- pRESTHandle, |
|
21 |
-- pSocket |
|
22 |
-- ); |
|
23 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
24 |
-+ VmRESTDisconnectClient( |
|
25 |
-+ pRESTHandle, |
|
26 |
-+ pSocket |
|
27 |
-+ ); |
|
28 |
- |
|
29 |
- /**** free request object memory ****/ |
|
30 |
- if (pRequest) |
|
31 |
-@@ -542,7 +541,7 @@ VmRESTTcpReceiveNewData( |
|
32 |
- |
|
33 |
- error: |
|
34 |
- |
|
35 |
-- VMREST_LOG_DEBUG(pRESTHandle,"ERROR code %u", dwError); |
|
36 |
-+ VMREST_LOG_ERROR(pRESTHandle,"ERROR code %u", dwError); |
|
37 |
- goto cleanup; |
|
38 |
- } |
|
39 |
- |
|
40 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
41 |
-index 029633a..79c7a38 100644 |
|
42 |
-+++ b/transport/posix/socket.c |
|
43 |
-@@ -539,6 +539,8 @@ VmSockPosixWaitForEvent( |
|
44 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
45 |
- } |
|
46 |
- |
|
47 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"Notification on socket fd %d", pEventSocket->fd); |
|
48 |
-+ |
|
49 |
- if (pEvent->events & (EPOLLERR | EPOLLHUP)) |
|
50 |
- { |
|
51 |
- eventType = VM_SOCK_EVENT_TYPE_CONNECTION_CLOSED; |
|
52 |
-@@ -919,8 +921,23 @@ VmSockPosixRead( |
|
53 |
- |
|
54 |
- error: |
|
55 |
- |
|
56 |
-- if (pszBufPrev && pSocket) |
|
57 |
-+ if (pSocket) |
|
58 |
-+ { |
|
59 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Socket read failed with Socket fd %d, dwError = %u, nRead = %d, errno = %u, errorCode = %u", pSocket->fd, dwError, nRead, errno, errorCode); |
|
60 |
-+ } |
|
61 |
-+ else |
|
62 |
-+ { |
|
63 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Socket read failed with dwError = %u, nRead = %d, errno = %u, errorCode = %u", dwError, nRead, errno, errorCode); |
|
64 |
-+ } |
|
65 |
-+ |
|
66 |
-+ if (pszBufPrev && pSocket && pRESTHandle->pSockContext) |
|
67 |
- { |
|
68 |
-+ /**** Delete the socket from poller ****/ |
|
69 |
-+ VmSockPosixEventQueueDelete_inlock( |
|
70 |
-+ pRESTHandle->pSockContext->pEventQueue, |
|
71 |
-+ pSocket |
|
72 |
-+ ); |
|
73 |
-+ |
|
74 |
- VmRESTFreeMemory(pszBufPrev); |
|
75 |
- pszBufPrev = NULL; |
|
76 |
- pSocket->pszBuffer = NULL; |
|
77 |
-@@ -1542,6 +1559,14 @@ VmSockPosixSetRequestHandle( |
|
78 |
- pSocket->pTimerSocket |
|
79 |
- ); |
|
80 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
81 |
-+ |
|
82 |
-+ /**** Delete actual IO socket from poller ****/ |
|
83 |
-+ dwError = VmSockPosixEventQueueDelete_inlock( |
|
84 |
-+ pQueue, |
|
85 |
-+ pSocket |
|
86 |
-+ ); |
|
87 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
88 |
-+ |
|
89 |
- if (pSocket->pTimerSocket->fd > 0) |
|
90 |
- { |
|
91 |
- close(pSocket->pTimerSocket->fd); |
92 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,123 +0,0 @@ |
1 |
-From a7aba08f7fd2700c92fd9661eee212755ba8795e Mon Sep 17 00:00:00 2001 |
|
2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
3 |
-Date: Thu, 7 Dec 2017 12:53:17 -0800 |
|
4 |
-Subject: [PATCH] Fixing tls: unexpected message ERROR |
|
5 |
- |
|
6 |
-Change-Id: I63dce89d4dcfa445b6594d4b776ef8827f1498ff |
|
7 |
-(cherry picked from commit 424f6d0f3435eccad781d39ef0c656a00395dc46) |
|
8 |
- transport/posix/socket.c | 34 +++++++++++++++++++++++----------- |
|
9 |
- 1 file changed, 23 insertions(+), 11 deletions(-) |
|
10 |
- |
|
11 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
12 |
-index d3a3dbc..18cef89 100644 |
|
13 |
-+++ b/transport/posix/socket.c |
|
14 |
-@@ -576,7 +576,6 @@ VmSockPosixWaitForEvent( |
|
15 |
- FALSE |
|
16 |
- ); |
|
17 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
18 |
-- |
|
19 |
- } |
|
20 |
- |
|
21 |
- dwError = VmSockPosixEventQueueAdd_inlock( |
|
22 |
-@@ -895,7 +894,7 @@ VmSockPosixRead( |
|
23 |
- } |
|
24 |
- else |
|
25 |
- { |
|
26 |
-- VMREST_LOG_ERROR(pRESTHandle,"%s","Unknown socket read error: errno %u, errorCode %u, nRead %d", errno, errorCode, nRead); |
|
27 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Unknown socket read error: errno %u, errorCode %u, nRead %d", errno, errorCode, nRead); |
|
28 |
- dwError = REST_ENGINE_FAILURE; |
|
29 |
- } |
|
30 |
- } |
|
31 |
-@@ -1007,6 +1006,9 @@ VmSockPosixWrite( |
|
32 |
- |
|
33 |
- while(nWrittenTotal < nBufLen ) |
|
34 |
- { |
|
35 |
-+ nWritten = 0; |
|
36 |
-+ errorCode = 0; |
|
37 |
-+ errno = 0; |
|
38 |
- if (pRESTHandle->pSSLInfo->isSecure && (pSocket->ssl != NULL)) |
|
39 |
- { |
|
40 |
- nWritten = SSL_write(pSocket->ssl,(pszBuffer + nWrittenTotal),nRemaining); |
|
41 |
-@@ -1030,7 +1032,7 @@ VmSockPosixWrite( |
|
42 |
- } |
|
43 |
- else |
|
44 |
- { |
|
45 |
-- if (errorCode == EAGAIN || errorCode == EWOULDBLOCK || errorCode == SSL_ERROR_WANT_WRITE) |
|
46 |
-+ if ((nWritten < 0) && (errorCode == EAGAIN || errorCode == EWOULDBLOCK || errorCode == SSL_ERROR_WANT_WRITE)) |
|
47 |
- { |
|
48 |
- if (timeOutSec >= 0) |
|
49 |
- { |
|
50 |
-@@ -1101,6 +1103,8 @@ VmSockPosixCloseSocket( |
|
51 |
- ) |
|
52 |
- { |
|
53 |
- DWORD dwError = REST_ENGINE_SUCCESS; |
|
54 |
-+ int ret = 0; |
|
55 |
-+ uint32_t errorCode = 0; |
|
56 |
- BOOLEAN bLocked = FALSE; |
|
57 |
- |
|
58 |
- if (!pRESTHandle || !pSocket ) |
|
59 |
-@@ -1121,18 +1125,24 @@ VmSockPosixCloseSocket( |
|
60 |
- pSocket->pTimerSocket->fd = -1; |
|
61 |
- } |
|
62 |
- |
|
63 |
-+ if (pRESTHandle->pSSLInfo->isSecure && pSocket->ssl) |
|
64 |
-+ { |
|
65 |
-+ ret = SSL_shutdown(pSocket->ssl); |
|
66 |
-+ if (ret < 0) |
|
67 |
-+ { |
|
68 |
-+ errorCode = SSL_get_error(pSocket->ssl, ret); |
|
69 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Error on SSL_shutdown on socket %d, return value %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
70 |
-+ } |
|
71 |
-+ SSL_free(pSocket->ssl); |
|
72 |
-+ pSocket->ssl = NULL; |
|
73 |
-+ } |
|
74 |
-+ |
|
75 |
- if (pSocket->fd >= 0) |
|
76 |
- { |
|
77 |
- close(pSocket->fd); |
|
78 |
- pSocket->fd = -1; |
|
79 |
- } |
|
80 |
- |
|
81 |
-- if (pRESTHandle->pSSLInfo->isSecure && pSocket->ssl) |
|
82 |
-- { |
|
83 |
-- SSL_shutdown(pSocket->ssl); |
|
84 |
-- SSL_free(pSocket->ssl); |
|
85 |
-- pSocket->ssl = NULL; |
|
86 |
-- } |
|
87 |
- |
|
88 |
- cleanup: |
|
89 |
- |
|
90 |
-@@ -1742,6 +1752,7 @@ VmSockPosixIsSafeToCloseConnOnTimeOut( |
|
91 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
92 |
- |
|
93 |
- pSocket = pTimerSocket->pIoSocket; |
|
94 |
-+ errno = 0; |
|
95 |
- |
|
96 |
- if ((pRESTHandle->pSSLInfo->isSecure) && (pSocket->ssl)) |
|
97 |
- { |
|
98 |
-@@ -1771,6 +1782,7 @@ VmSockPosixIsSafeToCloseConnOnTimeOut( |
|
99 |
- do |
|
100 |
- { |
|
101 |
- errorCode = 0; |
|
102 |
-+ errno = 0; |
|
103 |
- nRead = 0; |
|
104 |
- nRead = read(pTimerSocket->fd, &res, sizeof(res)); |
|
105 |
- errorCode = errno; |
|
106 |
-@@ -1918,13 +1930,13 @@ VmRESTAcceptSSLContext( |
|
107 |
- } |
|
108 |
- else if ((ret == -1) && ((errorCode == SSL_ERROR_WANT_READ) || (errorCode == SSL_ERROR_WANT_WRITE))) |
|
109 |
- { |
|
110 |
-- VMREST_LOG_DEBUG(pRESTHandle,"SSL handshake not completed for socket %d", pSocket->fd); |
|
111 |
-+ VMREST_LOG_DEBUG(pRESTHandle," SSL handshake not completed for socket %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
112 |
- pSocket->bSSLHandShakeCompleted = FALSE; |
|
113 |
- bReArm = TRUE; |
|
114 |
- } |
|
115 |
- else |
|
116 |
- { |
|
117 |
-- VMREST_LOG_ERROR(pRESTHandle, "SSL handshake failed...connection will be closed for socket with fd %d", pSocket->fd); |
|
118 |
-+ VMREST_LOG_ERROR(pRESTHandle, "SSL handshake failed...connection will be closed for socket with fd %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
119 |
- dwError = VMREST_TRANSPORT_SSL_ACCEPT_FAILED; |
|
120 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
121 |
- } |
122 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,151 +0,0 @@ |
1 |
-From 56c8c0ffd82c8fe8c396d8c00f23688adcdc9ecd Mon Sep 17 00:00:00 2001 |
|
2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
3 |
-Date: Wed, 15 Nov 2017 17:24:44 -0800 |
|
4 |
-Subject: [PATCH] Remove init/shutdown of syslog from library |
|
5 |
- |
|
6 |
-Change-Id: I7705f44c468d2ce69a15b531e108ef0cfbe391b8 |
|
7 |
- build/package/rpm/c-rest-engine.spec | 4 +++- |
|
8 |
- common/logging.c | 45 ++++++++---------------------------- |
|
9 |
- server/vmrestd/main.c | 8 ++++++- |
|
10 |
- 3 files changed, 20 insertions(+), 37 deletions(-) |
|
11 |
- |
|
12 |
-diff --git a/build/package/rpm/c-rest-engine.spec b/build/package/rpm/c-rest-engine.spec |
|
13 |
-index 8730113..02c1e62 100644 |
|
14 |
-+++ b/build/package/rpm/c-rest-engine.spec |
|
15 |
-@@ -1,7 +1,7 @@ |
|
16 |
- Name: c-rest-engine |
|
17 |
- Summary: Minimal http(s) server library |
|
18 |
- Version: 1.1 |
|
19 |
--Release: 1%{?dist} |
|
20 |
-+Release: 3%{?dist} |
|
21 |
- Group: Applications/System |
|
22 |
- Vendor: VMware, Inc. |
|
23 |
- License: Apache 2.0 |
|
24 |
-diff --git a/common/logging.c b/common/logging.c |
|
25 |
-index 6bef25c..385c0b6 100644 |
|
26 |
-+++ b/common/logging.c |
|
27 |
-@@ -41,13 +41,7 @@ VmRESTLogInitialize( |
|
28 |
- } |
|
29 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
30 |
- |
|
31 |
-- if (pRESTHandle->pRESTConfig->useSysLog) |
|
32 |
-- { |
|
33 |
-- /**** Use syslog ****/ |
|
34 |
-- openlog(pRESTHandle->pRESTConfig->pszDaemonName, 0, LOG_DAEMON); |
|
35 |
-- setlogmask(LOG_UPTO(logLevelToSysLogLevel(pRESTHandle->debugLogLevel))); |
|
36 |
-- } |
|
37 |
-- else if (!(IsNullOrEmptyString(pRESTHandle->pRESTConfig->pszDebugLogFile))) |
|
38 |
-+ if ((!(IsNullOrEmptyString(pRESTHandle->pRESTConfig->pszDebugLogFile))) && (pRESTHandle->pRESTConfig->useSysLog == FALSE)) |
|
39 |
- { |
|
40 |
- if ((pRESTHandle->logFile = fopen(pRESTHandle->pRESTConfig->pszDebugLogFile, "a")) == NULL) |
|
41 |
- { |
|
42 |
-@@ -55,10 +49,6 @@ VmRESTLogInitialize( |
|
43 |
- dwError = REST_ENGINE_FAILURE; |
|
44 |
- } |
|
45 |
- } |
|
46 |
-- else |
|
47 |
-- { |
|
48 |
-- dwError = REST_ENGINE_FAILURE; |
|
49 |
-- } |
|
50 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
51 |
- |
|
52 |
- cleanup: |
|
53 |
-@@ -76,11 +66,7 @@ VmRESTLogTerminate( |
|
54 |
- PVMREST_HANDLE pRESTHandle |
|
55 |
- ) |
|
56 |
- { |
|
57 |
-- if (pRESTHandle && pRESTHandle->pRESTConfig->useSysLog) |
|
58 |
-- { |
|
59 |
-- closelog(); |
|
60 |
-- } |
|
61 |
-- else if (pRESTHandle && pRESTHandle->logFile != NULL) |
|
62 |
-+ if (pRESTHandle && pRESTHandle->logFile != NULL) |
|
63 |
- { |
|
64 |
- fclose(pRESTHandle->logFile); |
|
65 |
- pRESTHandle->logFile = NULL; |
|
66 |
-@@ -95,10 +81,9 @@ VmRESTLog( |
|
67 |
- ...) |
|
68 |
- { |
|
69 |
- char extraLogMessage[EXTRA_LOG_MESSAGE_LEN] = {0}; |
|
70 |
-- struct timespec tspec = {0}; |
|
71 |
-- time_t ltime; |
|
72 |
-- struct tm mytm = {0}; |
|
73 |
- char logMessage[MAX_LOG_MESSAGE_LEN]; |
|
74 |
-+ struct tm* tm_info = NULL; |
|
75 |
-+ struct timeval tv = {0}; |
|
76 |
- |
|
77 |
- va_list va; |
|
78 |
- const char* logLevelTag = ""; |
|
79 |
-@@ -115,30 +100,20 @@ VmRESTLog( |
|
80 |
- vsnprintf( logMessage, sizeof(logMessage), fmt, va ); |
|
81 |
- logMessage[sizeof(logMessage)-1] = '\0'; |
|
82 |
- va_end( va ); |
|
83 |
-- ltime = time(<ime); |
|
84 |
-+ gettimeofday(&tv, NULL); |
|
85 |
-+ |
|
86 |
-+ tm_info = localtime(&tv.tv_sec); |
|
87 |
- logLevelTag = logLevelToTag(level); |
|
88 |
-- localtime_r(<ime, &mytm); |
|
89 |
-- snprintf(extraLogMessage, sizeof(extraLogMessage) - 1, |
|
90 |
-- "%4d%2d%2d%2d%2d%2d.%03ld:t@%lu:%-3.7s: ", |
|
91 |
-- mytm.tm_year+1900, |
|
92 |
-- mytm.tm_mon+1, |
|
93 |
-- mytm.tm_mday, |
|
94 |
-- mytm.tm_hour, |
|
95 |
-- mytm.tm_min, |
|
96 |
-- mytm.tm_sec, |
|
97 |
-- tspec.tv_nsec/NSECS_PER_MSEC, |
|
98 |
-- (unsigned long) pthread_self(), |
|
99 |
-- logLevelTag? logLevelTag : "UNKNOWN"); |
|
100 |
-+ strftime(extraLogMessage, sizeof(extraLogMessage) - 1, "%F %T", tm_info); |
|
101 |
- |
|
102 |
- if (pRESTHandle->pRESTConfig->useSysLog) |
|
103 |
- { |
|
104 |
- sysLogLevel = logLevelToSysLogLevel(level); |
|
105 |
-- snprintf(extraLogMessage, sizeof(extraLogMessage) - 1, "t@%lu: ", (unsigned long) pthread_self()); |
|
106 |
-- syslog(sysLogLevel, "%s: %s%s", logLevelToTag(level), extraLogMessage, logMessage); |
|
107 |
-+ syslog(sysLogLevel, "%s:%lu t@%lu %-3.7s: %s\n", extraLogMessage, (long unsigned)(tv.tv_usec), (unsigned long) pthread_self(),(logLevelTag? logLevelTag : "UNKNOWN"),logMessage); |
|
108 |
- } |
|
109 |
- else if (pRESTHandle->logFile != NULL) |
|
110 |
- { |
|
111 |
-- fprintf(pRESTHandle->logFile, "%s%s\n", extraLogMessage, logMessage); |
|
112 |
-+ fprintf(pRESTHandle->logFile, "%s:%lu t@%lu %-3.7s: %s\n", extraLogMessage, (long unsigned)(tv.tv_usec), (unsigned long) pthread_self(),(logLevelTag? logLevelTag : "UNKNOWN"),logMessage); |
|
113 |
- fflush( pRESTHandle->logFile ); |
|
114 |
- } |
|
115 |
- } |
|
116 |
-diff --git a/server/vmrestd/main.c b/server/vmrestd/main.c |
|
117 |
-index 353f597..214b28d 100644 |
|
118 |
-+++ b/server/vmrestd/main.c |
|
119 |
-@@ -116,7 +116,7 @@ int main() |
|
120 |
- pConfig1->maxDataPerConnMB = 10; |
|
121 |
- pConfig1->nWorkerThr = 5; |
|
122 |
- pConfig1->nClientCnt = 5; |
|
123 |
-- pConfig1->useSysLog = FALSE; |
|
124 |
-+ pConfig1->useSysLog = TRUE; |
|
125 |
- pConfig1->pszSSLCertificate = "/root/mycert.pem"; |
|
126 |
- pConfig1->isSecure = TRUE; |
|
127 |
- pConfig1->pszSSLKey = "/root/mycert.pem"; |
|
128 |
-@@ -127,6 +127,10 @@ int main() |
|
129 |
- pConfig1->pszSSLCipherList = NULL; |
|
130 |
- pConfig1->SSLCtxOptionsFlag = 0; |
|
131 |
- |
|
132 |
-+ /**** Init sys log ****/ |
|
133 |
-+ openlog("VMREST_KAUSHIK", 0, LOG_DAEMON); |
|
134 |
-+ setlogmask(LOG_UPTO(LOG_DEBUG)); |
|
135 |
-+ |
|
136 |
- dwError = VmRESTInit(pConfig, &gpRESTHandle); |
|
137 |
- dwError = VmRESTInit(pConfig1, &gpRESTHandle1); |
|
138 |
- |
|
139 |
-@@ -177,6 +181,8 @@ int main() |
|
140 |
- // VmRESTShutdownSSL(sslCtx1); |
|
141 |
- #endif |
|
142 |
- |
|
143 |
-+ closelog(); |
|
144 |
-+ |
|
145 |
- return dwError; |
|
146 |
- |
|
147 |
- } |