Change-Id: Ic85e68af5c7238a216138e2c8838811074c85ac3
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4790
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Kumar Kaushik <kaushikk@vmware.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,158 +0,0 @@ |
| 1 |
-From 4c271a2f34167495ed82da3e7ada52f4808fe121 Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
| 3 |
-Date: Tue, 6 Feb 2018 16:51:09 -0800 |
|
| 4 |
-Subject: [PATCH] Fixing bad memory write bug |
|
| 5 |
- |
|
| 6 |
-Change-Id: I483b13d2b2f99be7ebbbc77ed4f2dbf41aa7f580 |
|
| 7 |
- test/scripts/BUGS_TC/BUG-2052415/README | 41 ++++++++++++++ |
|
| 8 |
- test/scripts/BUGS_TC/BUG-2052415/restclient.c | 79 +++++++++++++++++++++++++++ |
|
| 9 |
- transport/posix/socket.c | 1 + |
|
| 10 |
- 3 files changed, 121 insertions(+) |
|
| 11 |
- create mode 100644 test/scripts/BUGS_TC/BUG-2052415/README |
|
| 12 |
- create mode 100644 test/scripts/BUGS_TC/BUG-2052415/restclient.c |
|
| 13 |
- |
|
| 14 |
-diff --git a/test/scripts/BUGS_TC/BUG-2052415/README b/test/scripts/BUGS_TC/BUG-2052415/README |
|
| 15 |
-new file mode 100644 |
|
| 16 |
-index 0000000..814a32a |
|
| 17 |
-+++ b/test/scripts/BUGS_TC/BUG-2052415/README |
|
| 18 |
-@@ -0,0 +1,41 @@ |
|
| 19 |
-+Bugzilla Id: 2052415 |
|
| 20 |
-+ |
|
| 21 |
-+Category: Catastrophic/Crash |
|
| 22 |
-+ |
|
| 23 |
-+Description: |
|
| 24 |
-+Server crash observed when client opens number of connection and times out. No data is sent. |
|
| 25 |
-+ |
|
| 26 |
-+Step to reproduce: |
|
| 27 |
-+ |
|
| 28 |
-+Specific configuration: |
|
| 29 |
-+1. Worker threads count 2. |
|
| 30 |
-+2. No Secure connection required. |
|
| 31 |
-+ |
|
| 32 |
-+ |
|
| 33 |
-+Start server( Keep it running ) |
|
| 34 |
-+Refer RUN-SIMPLE-SERVER doc in test/scripts directory. (TODO) |
|
| 35 |
-+ |
|
| 36 |
-+Open terminal on Ubuntu VM( or any other distro) |
|
| 37 |
-+1. Wget the source file from the same directory (restclient.c) |
|
| 38 |
-+2. Edit SERVER_IP and SERVER_PORT macro in the source file to your server. |
|
| 39 |
-+3. Compile the downloaded client source (gcc -o restclient restclient.c) |
|
| 40 |
-+4. Install "parallel" on the Ubuntu distro |
|
| 41 |
-+5. Run following command |
|
| 42 |
-+ "seq 0 100 | parallel -j50 ./restclient" |
|
| 43 |
-+ |
|
| 44 |
-+ |
|
| 45 |
-+Server will crash. This might take anything between couple of second to 10-15 mins. |
|
| 46 |
-+ |
|
| 47 |
-+ |
|
| 48 |
-+ROOT CAUSE: |
|
| 49 |
-+Bad memory write happened for back pointer reference for timer socket which was already freed. |
|
| 50 |
-+This was reported by valgrind also. |
|
| 51 |
-+ |
|
| 52 |
-+Fix: |
|
| 53 |
-+Setting appropiate back pointer to NULL at right place. |
|
| 54 |
-+ |
|
| 55 |
-+ |
|
| 56 |
-+Test: |
|
| 57 |
-+Ran the same test for serveral hours. No crash seen. |
|
| 58 |
-+Ran under valgrind, no bad write reported. |
|
| 59 |
-+All c-rest-engine BVT |
|
| 60 |
-diff --git a/test/scripts/BUGS_TC/BUG-2052415/restclient.c b/test/scripts/BUGS_TC/BUG-2052415/restclient.c |
|
| 61 |
-new file mode 100644 |
|
| 62 |
-index 0000000..a352055 |
|
| 63 |
-+++ b/test/scripts/BUGS_TC/BUG-2052415/restclient.c |
|
| 64 |
-@@ -0,0 +1,79 @@ |
|
| 65 |
-+/************************************************************************** |
|
| 66 |
-+* This test client will open connection to server but will not send any |
|
| 67 |
-+* data. This will make server to timeout and execute the timeout code |
|
| 68 |
-+* path. Please refer README in the same folder for more information |
|
| 69 |
-+**************************************************************************/ |
|
| 70 |
-+ |
|
| 71 |
-+#include <stdio.h> |
|
| 72 |
-+#include <stdlib.h> |
|
| 73 |
-+#include <unistd.h> |
|
| 74 |
-+#include <errno.h> |
|
| 75 |
-+#include <string.h> |
|
| 76 |
-+#include <netdb.h> |
|
| 77 |
-+#include <sys/types.h> |
|
| 78 |
-+#include <netinet/in.h> |
|
| 79 |
-+#include <sys/socket.h> |
|
| 80 |
-+#include <arpa/inet.h> |
|
| 81 |
-+#include <fcntl.h> |
|
| 82 |
-+ |
|
| 83 |
-+/************** EDIT THIS **************/ |
|
| 84 |
-+ |
|
| 85 |
-+#define SERVER_IP "172.16.127.131" |
|
| 86 |
-+#define SERVER_PORT "81" |
|
| 87 |
-+ |
|
| 88 |
-+/***************************************/ |
|
| 89 |
-+ |
|
| 90 |
-+ |
|
| 91 |
-+#define MAXDATASIZE 4096 |
|
| 92 |
-+ |
|
| 93 |
-+ |
|
| 94 |
-+int main(int argc, char *argv[]) |
|
| 95 |
-+{
|
|
| 96 |
-+ int sockfd = -1; |
|
| 97 |
-+ int nBytes = 0; |
|
| 98 |
-+ char buf[MAXDATASIZE] = {0};
|
|
| 99 |
-+ struct addrinfo hints, *servinfo, *p; |
|
| 100 |
-+ int rv; |
|
| 101 |
-+ char s[INET6_ADDRSTRLEN]; |
|
| 102 |
-+ |
|
| 103 |
-+again: |
|
| 104 |
-+ memset(&hints, 0, sizeof(hints)); |
|
| 105 |
-+ hints.ai_family = AF_UNSPEC; |
|
| 106 |
-+ hints.ai_socktype = SOCK_STREAM; |
|
| 107 |
-+ |
|
| 108 |
-+ if ((rv = getaddrinfo(SERVER_IP, SERVER_PORT, &hints, &servinfo)) != 0) {
|
|
| 109 |
-+ fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); |
|
| 110 |
-+ return 1; |
|
| 111 |
-+ } |
|
| 112 |
-+ |
|
| 113 |
-+ for(p = servinfo; p != NULL; p = p->ai_next) {
|
|
| 114 |
-+ if ((sockfd = socket(p->ai_family, p->ai_socktype, |
|
| 115 |
-+ p->ai_protocol)) == -1) {
|
|
| 116 |
-+ perror("client: socket");
|
|
| 117 |
-+ continue; |
|
| 118 |
-+ } |
|
| 119 |
-+ |
|
| 120 |
-+ if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
|
|
| 121 |
-+ close(sockfd); |
|
| 122 |
-+ perror("client: connect");
|
|
| 123 |
-+ continue; |
|
| 124 |
-+ } |
|
| 125 |
-+ |
|
| 126 |
-+ break; |
|
| 127 |
-+ } |
|
| 128 |
-+ |
|
| 129 |
-+ if (p == NULL) {
|
|
| 130 |
-+ printf("client: failed to connect\n");
|
|
| 131 |
-+ return 2; |
|
| 132 |
-+ } |
|
| 133 |
-+ |
|
| 134 |
-+ freeaddrinfo(servinfo); |
|
| 135 |
-+ |
|
| 136 |
-+ nBytes = read(sockfd, buf, MAXDATASIZE); |
|
| 137 |
-+ |
|
| 138 |
-+ close(sockfd); |
|
| 139 |
-+ goto again; |
|
| 140 |
-+ |
|
| 141 |
-+ return 0; |
|
| 142 |
-+ |
|
| 143 |
-+} |
|
| 144 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
| 145 |
-index 207075b..ec7ed3d 100644 |
|
| 146 |
-+++ b/transport/posix/socket.c |
|
| 147 |
-@@ -661,6 +661,7 @@ VmSockPosixWaitForEvent( |
|
| 148 |
- ); |
|
| 149 |
- } |
|
| 150 |
- } |
|
| 151 |
-+ pEventSocket->pIoSocket->pTimerSocket = NULL; |
|
| 152 |
- } |
|
| 153 |
- |
|
| 154 |
- /** Close and free the timer socket ****/ |
| ... | ... |
@@ -1,7 +1,7 @@ |
| 1 | 1 |
Name: c-rest-engine |
| 2 | 2 |
Summary: minimal http(s) server library |
| 3 |
-Version: 1.1 |
|
| 4 |
-Release: 10%{?dist}
|
|
| 3 |
+Version: 1.2 |
|
| 4 |
+Release: 1%{?dist}
|
|
| 5 | 5 |
Group: Applications/System |
| 6 | 6 |
Vendor: VMware, Inc. |
| 7 | 7 |
License: Apache 2.0 |
| ... | ... |
@@ -12,17 +12,7 @@ Requires: openssl >= 1.0.1 |
| 12 | 12 |
BuildRequires: coreutils >= 8.22 |
| 13 | 13 |
BuildRequires: openssl-devel >= 1.0.1 |
| 14 | 14 |
Source0: %{name}-%{version}.tar.gz
|
| 15 |
-Patch0: socket_RW.patch |
|
| 16 |
-Patch1: syslog_noInit.patch |
|
| 17 |
-Patch2: socket_logging.patch |
|
| 18 |
-Patch3: errno_init.patch |
|
| 19 |
-Patch4: ssl_shutdown.patch |
|
| 20 |
-Patch5: minimal_request_logging.patch |
|
| 21 |
-Patch6: connection_timeout.patch |
|
| 22 |
-Patch7: reqLine_parsing_check.patch |
|
| 23 |
-Patch8: bad_mem_write.patch |
|
| 24 |
-Patch9: instance_state.patch |
|
| 25 |
-%define sha1 c-rest-engine=a25927fd98ec92df5e210cc4941fa626604636f6 |
|
| 15 |
+%define sha1 c-rest-engine=25aa9d1f2680e26114dee18365c510692552f8e4 |
|
| 26 | 16 |
|
| 27 | 17 |
%description |
| 28 | 18 |
c-rest-engine is a minimal embedded http(s) server written in C. |
| ... | ... |
@@ -40,16 +30,6 @@ development libs and header files for c-rest-engine |
| 40 | 40 |
|
| 41 | 41 |
%prep |
| 42 | 42 |
%setup -q |
| 43 |
-%patch0 -p1 |
|
| 44 |
-%patch1 -p1 |
|
| 45 |
-%patch2 -p1 |
|
| 46 |
-%patch3 -p1 |
|
| 47 |
-%patch4 -p1 |
|
| 48 |
-%patch5 -p1 |
|
| 49 |
-%patch6 -p1 |
|
| 50 |
-%patch7 -p1 |
|
| 51 |
-%patch8 -p1 |
|
| 52 |
-%patch9 -p1 |
|
| 53 | 43 |
|
| 54 | 44 |
%build |
| 55 | 45 |
cd build |
| ... | ... |
@@ -82,6 +62,8 @@ find %{buildroot} -name '*.la' -delete
|
| 82 | 82 |
# %doc ChangeLog README COPYING |
| 83 | 83 |
|
| 84 | 84 |
%changelog |
| 85 |
+* Wed Feb 14 2018 Kumar Kaushik <kaushikk@vmware.com> 1.2-1 |
|
| 86 |
+- Upgrading to version 1.2. Removing all upstream patches. |
|
| 85 | 87 |
* Wed Feb 14 2018 Kumar Kaushik <kaushikk@vmware.com> 1.1-10 |
| 86 | 88 |
- Maintaing instance state for API calls safety. |
| 87 | 89 |
* Tue Feb 06 2018 Kumar Kaushik <kaushikk@vmware.com> 1.1-9 |
| 88 | 90 |
deleted file mode 100644 |
| ... | ... |
@@ -1,832 +0,0 @@ |
| 1 |
-From 96a49b724295422ceb6465553fdf0da20e5a3b6d Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
| 3 |
-Date: Mon, 29 Jan 2018 19:30:18 -0800 |
|
| 4 |
-Subject: [PATCH] Handling timeout events for faulty application callback |
|
| 5 |
- |
|
| 6 |
-Change-Id: I9a412f6d7cf2c3345c73f0581906829bd183e445 |
|
| 7 |
- common/sockinterface.c | 26 ++- |
|
| 8 |
- include/public/vmrest.h | 1 + |
|
| 9 |
- include/vmrestdefines.h | 9 + |
|
| 10 |
- server/restengine/httpAllocStruct.c | 4 +- |
|
| 11 |
- server/restengine/httpProtocolHead.c | 7 +- |
|
| 12 |
- transport/posix/socket.c | 425 ++++++++++++++++++----------------- |
|
| 13 |
- transport/posix/structs.h | 1 + |
|
| 14 |
- 7 files changed, 257 insertions(+), 216 deletions(-) |
|
| 15 |
- |
|
| 16 |
-diff --git a/common/sockinterface.c b/common/sockinterface.c |
|
| 17 |
-index 403189c..9e7d404 100644 |
|
| 18 |
-+++ b/common/sockinterface.c |
|
| 19 |
-@@ -327,14 +327,13 @@ VmRESTHandleSocketEvent( |
|
| 20 |
- break; |
|
| 21 |
- |
|
| 22 |
- case VM_SOCK_EVENT_TYPE_CONNECTION_TIMEOUT: |
|
| 23 |
-- /**** Free Associated memory ****/ |
|
| 24 |
-- VMREST_LOG_DEBUG(pRESTHandle,"%s","EVENT-HANDLER: Connection timeout happened..Disconnecting client ..."); |
|
| 25 |
-- dwError = VmRESTOnConnectionTimeout( |
|
| 26 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"%s","EVENT-HANDLER: Connection timeout happened..Disconnecting client"); |
|
| 27 |
-+ dwError = VmRESTOnConnectionTimeout( |
|
| 28 |
- pRESTHandle, |
|
| 29 |
- pSocket |
|
| 30 |
- ); |
|
| 31 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 32 |
-- break; |
|
| 33 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 34 |
-+ break; |
|
| 35 |
- |
|
| 36 |
- case VM_SOCK_EVENT_TYPE_UNKNOWN: |
|
| 37 |
- VMREST_LOG_DEBUG(pRESTHandle,"%s","EVENT-HANDLER: Unknown Socket Event, do nothing"); |
|
| 38 |
-@@ -436,6 +435,7 @@ VmRESTTcpReceiveNewData( |
|
| 39 |
- char* pszBuffer = NULL; |
|
| 40 |
- uint32_t nProcessed = 0; |
|
| 41 |
- uint32_t nBufLen = 0; |
|
| 42 |
-+ uint32_t ret = REST_ENGINE_SUCCESS; |
|
| 43 |
- BOOLEAN bNextIO = FALSE; |
|
| 44 |
- |
|
| 45 |
- if (!pSocket || !pRESTHandle || !pQueue) |
|
| 46 |
-@@ -517,7 +517,7 @@ VmRESTTcpReceiveNewData( |
|
| 47 |
- |
|
| 48 |
- cleanup: |
|
| 49 |
- |
|
| 50 |
-- if (!bNextIO) |
|
| 51 |
-+ if (!bNextIO && dwError != REST_ENGINE_ERROR_DOUBLE_FAILURE) |
|
| 52 |
- {
|
|
| 53 |
- VMREST_LOG_DEBUG(pRESTHandle,"%s","Calling closed connection...."); |
|
| 54 |
- /**** Close connection ****/ |
|
| 55 |
-@@ -542,6 +542,20 @@ VmRESTTcpReceiveNewData( |
|
| 56 |
- error: |
|
| 57 |
- |
|
| 58 |
- VMREST_LOG_ERROR(pRESTHandle,"ERROR code %u", dwError); |
|
| 59 |
-+ |
|
| 60 |
-+ if ((dwError == VMREST_TRANSPORT_DEFERRED_TIMEOUT_PROCESS) && (bNextIO)) |
|
| 61 |
-+ {
|
|
| 62 |
-+ ret = VmRESTOnConnectionTimeout( |
|
| 63 |
-+ pRESTHandle, |
|
| 64 |
-+ pSocket |
|
| 65 |
-+ ); |
|
| 66 |
-+ |
|
| 67 |
-+ if (ret != REST_ENGINE_SUCCESS) |
|
| 68 |
-+ {
|
|
| 69 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Double failure on deferred timeout processing dwError, = %u", dwError); |
|
| 70 |
-+ dwError = REST_ENGINE_ERROR_DOUBLE_FAILURE; |
|
| 71 |
-+ } |
|
| 72 |
-+ } |
|
| 73 |
- goto cleanup; |
|
| 74 |
- } |
|
| 75 |
- |
|
| 76 |
-diff --git a/include/public/vmrest.h b/include/public/vmrest.h |
|
| 77 |
-index 3988266..5219952 100644 |
|
| 78 |
-+++ b/include/public/vmrest.h |
|
| 79 |
-@@ -32,6 +32,7 @@ |
|
| 80 |
- /**** REST ENGINE ERROR CODES ****/ |
|
| 81 |
- #define REST_ENGINE_SUCCESS 0 |
|
| 82 |
- #define REST_ENGINE_FAILURE 1 |
|
| 83 |
-+#define REST_ENGINE_ERROR_DOUBLE_FAILURE 99 |
|
| 84 |
- #define REST_ERROR_MISSING_CONFIG 100 |
|
| 85 |
- #define REST_ERROR_INVALID_CONFIG 101 |
|
| 86 |
- #define REST_ERROR_NO_MEMORY 102 |
|
| 87 |
-diff --git a/include/vmrestdefines.h b/include/vmrestdefines.h |
|
| 88 |
-index 914422a..8a37628 100644 |
|
| 89 |
-+++ b/include/vmrestdefines.h |
|
| 90 |
-@@ -63,6 +63,15 @@ |
|
| 91 |
- #define VMREST_TRANSPORT_COND_INIT_FAILED 61125 |
|
| 92 |
- #define VMREST_TRANSPORT_SERVER_THREAD_START_FAILED 61126 |
|
| 93 |
- |
|
| 94 |
-+ |
|
| 95 |
-+#define VMREST_TRANSPORT_DEFERRED_TIMEOUT_PROCESS 61127 |
|
| 96 |
-+#define VMREST_TRANSPORT_SOCK_READ_FAILED 61128 |
|
| 97 |
-+#define VMREST_TRANSPORT_SOCK_WRITE_FAILED 61129 |
|
| 98 |
-+#define VMREST_TRANSPORT_SOCK_GET_HANDLE_FAILED 61130 |
|
| 99 |
-+#define VMREST_TRANSPORT_SOCK_SET_HANDLE_FAILED 61131 |
|
| 100 |
-+#define VMREST_TRANSPORT_SOCK_DATA_OVER_LIMIT 61132 |
|
| 101 |
-+#define VMREST_TRANSPORT_REMOTE_CONN_CLOSED 61133 |
|
| 102 |
-+ |
|
| 103 |
- #define ERROR_TRANSPORT_INVALID_PARAMS 61040 |
|
| 104 |
- #define ERROR_TRANSPORT_VALIDATION_FAILED 61041 |
|
| 105 |
- |
|
| 106 |
-diff --git a/server/restengine/httpAllocStruct.c b/server/restengine/httpAllocStruct.c |
|
| 107 |
-index 64cb846..27aa9ed 100644 |
|
| 108 |
-+++ b/server/restengine/httpAllocStruct.c |
|
| 109 |
-@@ -519,11 +519,13 @@ VmRESTAllocateMiscQueue( |
|
| 110 |
- PMISC_HEADER_QUEUE pMiscQueue = NULL; |
|
| 111 |
- |
|
| 112 |
- dwError = VmRESTAllocateMemory( |
|
| 113 |
-- sizeof(VM_REST_HTTP_MESSAGE_BODY), |
|
| 114 |
-+ sizeof(MISC_HEADER_QUEUE), |
|
| 115 |
- (void**)&pMiscQueue |
|
| 116 |
- ); |
|
| 117 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 118 |
- |
|
| 119 |
-+ pMiscQueue->head = NULL; |
|
| 120 |
-+ |
|
| 121 |
- *ppMiscHeaderQueue = pMiscQueue; |
|
| 122 |
- |
|
| 123 |
- cleanup: |
|
| 124 |
-diff --git a/server/restengine/httpProtocolHead.c b/server/restengine/httpProtocolHead.c |
|
| 125 |
-index 18cff08..95089a3 100644 |
|
| 126 |
-+++ b/server/restengine/httpProtocolHead.c |
|
| 127 |
-@@ -1448,8 +1448,13 @@ VmRESTProcessBuffer( |
|
| 128 |
- if (ret != REST_ENGINE_SUCCESS) |
|
| 129 |
- {
|
|
| 130 |
- VMREST_LOG_ERROR(pRESTHandle,"%s","Double Failure case detected ...."); |
|
| 131 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","possible memory leak"); |
|
| 132 |
-+ dwError = REST_ENGINE_ERROR_DOUBLE_FAILURE; |
|
| 133 |
-+ } |
|
| 134 |
-+ else |
|
| 135 |
-+ {
|
|
| 136 |
-+ dwError = REST_ENGINE_SUCCESS; |
|
| 137 |
- } |
|
| 138 |
-- dwError = REST_ENGINE_SUCCESS; |
|
| 139 |
- goto cleanup; |
|
| 140 |
- |
|
| 141 |
- } |
|
| 142 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
| 143 |
-index 6c0e14e..207075b 100644 |
|
| 144 |
-+++ b/transport/posix/socket.c |
|
| 145 |
-@@ -81,13 +81,6 @@ VmSockPosixReArmTimer( |
|
| 146 |
- int milliSec |
|
| 147 |
- ); |
|
| 148 |
- |
|
| 149 |
--static |
|
| 150 |
--BOOLEAN |
|
| 151 |
--VmSockPosixIsSafeToCloseConnOnTimeOut( |
|
| 152 |
-- PVMREST_HANDLE pRESTHandle, |
|
| 153 |
-- PVM_SOCKET pTimerSocket |
|
| 154 |
-- ); |
|
| 155 |
-- |
|
| 156 |
- static |
|
| 157 |
- uint32_t |
|
| 158 |
- VmRESTAcceptSSLContext( |
|
| 159 |
-@@ -482,7 +475,9 @@ VmSockPosixWaitForEvent( |
|
| 160 |
- BOOLEAN bLocked = FALSE; |
|
| 161 |
- VM_SOCK_EVENT_TYPE eventType = VM_SOCK_EVENT_TYPE_UNKNOWN; |
|
| 162 |
- PVM_SOCKET pSocket = NULL; |
|
| 163 |
-+ BOOLEAN bFound = FALSE; |
|
| 164 |
- BOOLEAN bFreeEventQueue = 0; |
|
| 165 |
-+ int i = 0; |
|
| 166 |
- |
|
| 167 |
- if (!pQueue || !ppSocket || !pEventType) |
|
| 168 |
- {
|
|
| 169 |
-@@ -551,7 +546,7 @@ VmSockPosixWaitForEvent( |
|
| 170 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 171 |
- pSocket = pEventSocket; |
|
| 172 |
- } |
|
| 173 |
-- else if (pEventSocket->type == VM_SOCK_TYPE_LISTENER) |
|
| 174 |
-+ else if (pEventSocket->type == VM_SOCK_TYPE_LISTENER) // New connection request |
|
| 175 |
- {
|
|
| 176 |
- VMREST_LOG_INFO(pRESTHandle,"%s","C-REST-ENGINE: ======================== NEW REQUEST =========================="); |
|
| 177 |
- dwError = VmSockPosixAcceptConnection( |
|
| 178 |
-@@ -572,6 +567,7 @@ VmSockPosixWaitForEvent( |
|
| 179 |
- ); |
|
| 180 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 181 |
- |
|
| 182 |
-+ /**** Try SSL Handshake ****/ |
|
| 183 |
- dwError = VmRESTAcceptSSLContext( |
|
| 184 |
- pRESTHandle, |
|
| 185 |
- pSocket, |
|
| 186 |
-@@ -580,6 +576,7 @@ VmSockPosixWaitForEvent( |
|
| 187 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 188 |
- } |
|
| 189 |
- |
|
| 190 |
-+ /**** Start watching new connection ****/ |
|
| 191 |
- dwError = VmSockPosixEventQueueAdd_inlock( |
|
| 192 |
- pQueue, |
|
| 193 |
- TRUE, |
|
| 194 |
-@@ -593,9 +590,12 @@ VmSockPosixWaitForEvent( |
|
| 195 |
- pSocket |
|
| 196 |
- ); |
|
| 197 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 198 |
-+ |
|
| 199 |
- eventType = VM_SOCK_EVENT_TYPE_TCP_NEW_CONNECTION; |
|
| 200 |
-+ |
|
| 201 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"Timer fd %d associated with socket fd %d", pSocket->pTimerSocket->fd ,pSocket->fd); |
|
| 202 |
- } |
|
| 203 |
-- else if (pEventSocket->type == VM_SOCK_TYPE_SIGNAL) |
|
| 204 |
-+ else if (pEventSocket->type == VM_SOCK_TYPE_SIGNAL) // Shutdown library |
|
| 205 |
- {
|
|
| 206 |
- if (pQueue->bShutdown) |
|
| 207 |
- {
|
|
| 208 |
-@@ -614,58 +614,108 @@ VmSockPosixWaitForEvent( |
|
| 209 |
- eventType = VM_SOCK_EVENT_TYPE_DATA_AVAILABLE; |
|
| 210 |
- } |
|
| 211 |
- } |
|
| 212 |
-- else if (pEventSocket->type == VM_SOCK_TYPE_TIMER) |
|
| 213 |
-+ else if (pEventSocket->type == VM_SOCK_TYPE_TIMER) // Time out event |
|
| 214 |
- {
|
|
| 215 |
-- /**** No activity on the socket watched by poller till timeout ****/ |
|
| 216 |
-- if (VmSockPosixIsSafeToCloseConnOnTimeOut(pRESTHandle, pEventSocket)) |
|
| 217 |
-+ eventType = VM_SOCK_EVENT_TYPE_UNKNOWN; |
|
| 218 |
-+ pSocket = pEventSocket; |
|
| 219 |
-+ |
|
| 220 |
-+ VMREST_LOG_DEBUG(pRESTHandle, "Timeout event happened on timer fd %d", pSocket->fd); |
|
| 221 |
-+ |
|
| 222 |
-+ if (pSocket->pIoSocket != NULL) |
|
| 223 |
- {
|
|
| 224 |
-- pSocket = pEventSocket; |
|
| 225 |
-+ /*** Scan pQueue and look for IO event corresponding to this timer event ***/ |
|
| 226 |
-+ for ((i = (pQueue->iReady + 1)); i < pQueue->nReady ; i++) |
|
| 227 |
-+ {
|
|
| 228 |
-+ struct epoll_event* pEventTemp = &pQueue->pEventArray[i]; |
|
| 229 |
-+ PVM_SOCKET pEventSocketTemp = (PVM_SOCKET)pEventTemp->data.ptr; |
|
| 230 |
-+ if (pEventSocketTemp->fd == pEventSocket->pIoSocket->fd) |
|
| 231 |
-+ {
|
|
| 232 |
-+ pEventSocket->pIoSocket->pTimerSocket = NULL; |
|
| 233 |
-+ bFound = TRUE; |
|
| 234 |
-+ break; |
|
| 235 |
-+ } |
|
| 236 |
-+ } |
|
| 237 |
- |
|
| 238 |
-- /**** Delete timer socket from poller ****/ |
|
| 239 |
-- dwError = VmSockPosixEventQueueDelete_inlock( |
|
| 240 |
-- pQueue, |
|
| 241 |
-- pSocket |
|
| 242 |
-- ); |
|
| 243 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 244 |
-+ if (bFound) |
|
| 245 |
-+ {
|
|
| 246 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"Action: DEFERRED, IO sock found in queue(Succeeding), Io Sock %d, timer %d", pSocket->pIoSocket->fd, pSocket->fd ); |
|
| 247 |
-+ } |
|
| 248 |
-+ else |
|
| 249 |
-+ {
|
|
| 250 |
-+ if (pSocket->pIoSocket->bInUse == TRUE) |
|
| 251 |
-+ {
|
|
| 252 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"Action: DEFERRED, IO Soc in use, IoSocket %d, timer %d", pSocket->pIoSocket->fd, pSocket->fd ); |
|
| 253 |
-+ pEventSocket->pIoSocket->pTimerSocket = NULL; |
|
| 254 |
-+ } |
|
| 255 |
-+ else |
|
| 256 |
-+ {
|
|
| 257 |
-+ /**** We are good to close actual IO Socket here ****/ |
|
| 258 |
-+ VMREST_LOG_INFO(pRESTHandle,"Action: IO DELETION, IoSocket %d, timer %d", pSocket->pIoSocket->fd, pSocket->fd ); |
|
| 259 |
-+ eventType = VM_SOCK_EVENT_TYPE_CONNECTION_TIMEOUT; |
|
| 260 |
-+ pSocket = pSocket->pIoSocket; |
|
| 261 |
-+ |
|
| 262 |
-+ /**** Delete IO from queue ****/ |
|
| 263 |
-+ VmSockPosixEventQueueDelete_inlock( |
|
| 264 |
-+ pQueue, |
|
| 265 |
-+ pSocket |
|
| 266 |
-+ ); |
|
| 267 |
-+ } |
|
| 268 |
-+ } |
|
| 269 |
-+ } |
|
| 270 |
- |
|
| 271 |
-- /**** Delete actual IO socket from poller ****/ |
|
| 272 |
-- dwError = VmSockPosixEventQueueDelete_inlock( |
|
| 273 |
-- pQueue, |
|
| 274 |
-- pSocket->pIoSocket |
|
| 275 |
-- ); |
|
| 276 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 277 |
-+ /** Close and free the timer socket ****/ |
|
| 278 |
-+ VmSockPosixCloseSocket(pRESTHandle,pEventSocket); |
|
| 279 |
-+ VmSockPosixReleaseSocket(pRESTHandle,pEventSocket); |
|
| 280 |
- |
|
| 281 |
-- pSocket = pEventSocket->pIoSocket; |
|
| 282 |
-- eventType = VM_SOCK_EVENT_TYPE_CONNECTION_TIMEOUT; |
|
| 283 |
-+ if (eventType == VM_SOCK_EVENT_TYPE_UNKNOWN) |
|
| 284 |
-+ {
|
|
| 285 |
-+ pSocket = NULL; |
|
| 286 |
- } |
|
| 287 |
- } |
|
| 288 |
-- else |
|
| 289 |
-+ else // Data available on IO Socket |
|
| 290 |
- {
|
|
| 291 |
-- /**** Data is available over the socket ****/ |
|
| 292 |
-- pSocket = pEventSocket; |
|
| 293 |
-+ pSocket = pEventSocket; |
|
| 294 |
- |
|
| 295 |
-- /**** If SSL handshake is not yet complete, do the needful ****/ |
|
| 296 |
-- if ((pRESTHandle->pSSLInfo->isSecure) && (!(pSocket->bSSLHandShakeCompleted))) |
|
| 297 |
-- {
|
|
| 298 |
-- dwError = VmRESTAcceptSSLContext( |
|
| 299 |
-- pRESTHandle, |
|
| 300 |
-- pSocket, |
|
| 301 |
-- TRUE |
|
| 302 |
-- ); |
|
| 303 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 304 |
-- } |
|
| 305 |
-- else |
|
| 306 |
-- {
|
|
| 307 |
-- eventType = VM_SOCK_EVENT_TYPE_DATA_AVAILABLE; |
|
| 308 |
-+ /**** Mark IO socket in use - timer out event cannot modify IO till this is done ****/ |
|
| 309 |
-+ pSocket->bInUse = TRUE; |
|
| 310 |
- |
|
| 311 |
-- /**** Stop timer on the socket ****/ |
|
| 312 |
-- dwError = VmSockPosixReArmTimer( |
|
| 313 |
-- pRESTHandle, |
|
| 314 |
-- pSocket->pTimerSocket, |
|
| 315 |
-- 0 |
|
| 316 |
-- ); |
|
| 317 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 318 |
-- } |
|
| 319 |
-+ if (pSocket->pTimerSocket == NULL) |
|
| 320 |
-+ {
|
|
| 321 |
-+ /**** Time out already occurred on this socket.. request won't be processed ****/ |
|
| 322 |
-+ VmSockPosixCloseSocket(pRESTHandle,pSocket); |
|
| 323 |
-+ VmSockPosixReleaseSocket(pRESTHandle,pSocket); |
|
| 324 |
-+ } |
|
| 325 |
-+ else |
|
| 326 |
-+ {
|
|
| 327 |
-+ /**** Process data ****/ |
|
| 328 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"Data notification on socket fd %d", pSocket->fd); |
|
| 329 |
-+ |
|
| 330 |
-+ /**** If SSL handshake is not yet complete, do the needful ****/ |
|
| 331 |
-+ if ((pRESTHandle->pSSLInfo->isSecure) && (!(pSocket->bSSLHandShakeCompleted))) |
|
| 332 |
-+ {
|
|
| 333 |
-+ dwError = VmRESTAcceptSSLContext( |
|
| 334 |
-+ pRESTHandle, |
|
| 335 |
-+ pSocket, |
|
| 336 |
-+ TRUE |
|
| 337 |
-+ ); |
|
| 338 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 339 |
-+ |
|
| 340 |
-+ /**** We do not need IO any more ..mark as available for timer ****/ |
|
| 341 |
-+ pSocket->bInUse = FALSE; |
|
| 342 |
-+ } |
|
| 343 |
-+ else |
|
| 344 |
-+ {
|
|
| 345 |
-+ eventType = VM_SOCK_EVENT_TYPE_DATA_AVAILABLE; |
|
| 346 |
-+ |
|
| 347 |
-+ /*** Disarm timer associated with this IO socket .. dont delete ***/ |
|
| 348 |
-+ dwError = VmSockPosixReArmTimer( |
|
| 349 |
-+ pRESTHandle, |
|
| 350 |
-+ pSocket->pTimerSocket, |
|
| 351 |
-+ 0 |
|
| 352 |
-+ ); |
|
| 353 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 354 |
-+ } |
|
| 355 |
-+ } |
|
| 356 |
- } |
|
| 357 |
- } |
|
| 358 |
- pQueue->iReady++; |
|
| 359 |
-@@ -696,7 +746,7 @@ VmSockPosixWaitForEvent( |
|
| 360 |
- |
|
| 361 |
- error: |
|
| 362 |
- |
|
| 363 |
-- VMREST_LOG_ERROR(pRESTHandle,"%s","Socket layer - wait for event error"); |
|
| 364 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Error while processing socket event, dwError = %u", dwError); |
|
| 365 |
- if (ppSocket) |
|
| 366 |
- {
|
|
| 367 |
- *ppSocket = NULL; |
|
| 368 |
-@@ -884,8 +934,8 @@ VmSockPosixRead( |
|
| 369 |
- if (nPrevBuf >= pRESTHandle->pRESTConfig->maxDataPerConnMB) |
|
| 370 |
- {
|
|
| 371 |
- /**** Discard the request here itself. This might be the first read IO cycle ****/ |
|
| 372 |
-- VMREST_LOG_ERROR(pRESTHandle,"Total Data in request %u bytes is over allowed limit of %u bytes, closing connection...", nPrevBuf, pRESTHandle->pRESTConfig->maxDataPerConnMB); |
|
| 373 |
-- dwError = REST_ENGINE_FAILURE; |
|
| 374 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Total Data in request %u bytes is over allowed limit of %u bytes, closing connection with fd %d", nPrevBuf, pRESTHandle->pRESTConfig->maxDataPerConnMB, pSocket->fd); |
|
| 375 |
-+ dwError = VMREST_TRANSPORT_SOCK_DATA_OVER_LIMIT; |
|
| 376 |
- } |
|
| 377 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 378 |
- |
|
| 379 |
-@@ -897,8 +947,8 @@ VmSockPosixRead( |
|
| 380 |
- } |
|
| 381 |
- else |
|
| 382 |
- {
|
|
| 383 |
-- VMREST_LOG_ERROR(pRESTHandle,"Unknown socket read error: errno %u, errorCode %u, nRead %d", errno, errorCode, nRead); |
|
| 384 |
-- dwError = REST_ENGINE_FAILURE; |
|
| 385 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Socket read error: errno %u, errorCode %u, nRead %d", errno, errorCode, nRead); |
|
| 386 |
-+ dwError = VMREST_TRANSPORT_SOCK_READ_FAILED; |
|
| 387 |
- } |
|
| 388 |
- } |
|
| 389 |
- else |
|
| 390 |
-@@ -906,12 +956,12 @@ VmSockPosixRead( |
|
| 391 |
- if (nRead == 0) |
|
| 392 |
- {
|
|
| 393 |
- VMREST_LOG_ERROR(pRESTHandle,"%s","Socket Read Failed: Remote has closed the connection"); |
|
| 394 |
-- dwError = VM_SOCK_POSIX_ERROR_BROKEN_PIPE; |
|
| 395 |
-+ dwError = VMREST_TRANSPORT_SOCK_READ_FAILED; |
|
| 396 |
- } |
|
| 397 |
- else |
|
| 398 |
- {
|
|
| 399 |
- VMREST_LOG_ERROR(pRESTHandle, "Socket read failed with error code %u", errorCode); |
|
| 400 |
-- dwError = errorCode; |
|
| 401 |
-+ dwError = VMREST_TRANSPORT_SOCK_READ_FAILED; |
|
| 402 |
- } |
|
| 403 |
- } |
|
| 404 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 405 |
-@@ -936,29 +986,37 @@ VmSockPosixRead( |
|
| 406 |
- |
|
| 407 |
- error: |
|
| 408 |
- |
|
| 409 |
-- if (pSocket) |
|
| 410 |
-- {
|
|
| 411 |
-- 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); |
|
| 412 |
-- } |
|
| 413 |
-- else |
|
| 414 |
-- {
|
|
| 415 |
-- VMREST_LOG_ERROR(pRESTHandle,"Socket read failed with dwError = %u, nRead = %d, errno = %u, errorCode = %u", dwError, nRead, errno, errorCode); |
|
| 416 |
-- } |
|
| 417 |
-- |
|
| 418 |
-- if (pszBufPrev && pSocket && pRESTHandle->pSockContext) |
|
| 419 |
-+ if (pSocket && pRESTHandle->pSockContext) |
|
| 420 |
- {
|
|
| 421 |
- /**** Delete the socket from poller ****/ |
|
| 422 |
-- |
|
| 423 |
-- VmSockPosixEventQueueDelete_inlock( |
|
| 424 |
-+ VmSockPosixEventQueueDelete_inlock( |
|
| 425 |
- pRESTHandle->pSockContext->pEventQueue, |
|
| 426 |
- pSocket |
|
| 427 |
- ); |
|
| 428 |
-- |
|
| 429 |
-- VmRESTFreeMemory(pszBufPrev); |
|
| 430 |
-- pszBufPrev = NULL; |
|
| 431 |
-+ |
|
| 432 |
- pSocket->pszBuffer = NULL; |
|
| 433 |
- pSocket->nProcessed = 0; |
|
| 434 |
- pSocket->nBufData = 0; |
|
| 435 |
-+ |
|
| 436 |
-+ if (pSocket->pTimerSocket) |
|
| 437 |
-+ {
|
|
| 438 |
-+ VmSockPosixReArmTimer( |
|
| 439 |
-+ pRESTHandle, |
|
| 440 |
-+ pSocket->pTimerSocket, |
|
| 441 |
-+ ((pRESTHandle->pRESTConfig->connTimeoutSec) * 1000) |
|
| 442 |
-+ ); |
|
| 443 |
-+ |
|
| 444 |
-+ write(pSocket->pTimerSocket->fd, "NotifyPQ", 8); |
|
| 445 |
-+ pSocket->pTimerSocket->pIoSocket = NULL; |
|
| 446 |
-+ |
|
| 447 |
-+ } |
|
| 448 |
-+ |
|
| 449 |
-+ } |
|
| 450 |
-+ |
|
| 451 |
-+ if (pszBufPrev) |
|
| 452 |
-+ {
|
|
| 453 |
-+ VmRESTFreeMemory(pszBufPrev); |
|
| 454 |
-+ pszBufPrev = NULL; |
|
| 455 |
- } |
|
| 456 |
- |
|
| 457 |
- if (nBufLen) |
|
| 458 |
-@@ -1080,8 +1138,8 @@ VmSockPosixWrite( |
|
| 459 |
- |
|
| 460 |
- error: |
|
| 461 |
- |
|
| 462 |
-- VMREST_LOG_ERROR(pRESTHandle,"%s", "Socket write failed"); |
|
| 463 |
- goto cleanup; |
|
| 464 |
-+ |
|
| 465 |
- } |
|
| 466 |
- |
|
| 467 |
- VOID |
|
| 468 |
-@@ -1092,10 +1150,6 @@ VmSockPosixReleaseSocket( |
|
| 469 |
- {
|
|
| 470 |
- if (pSocket) |
|
| 471 |
- {
|
|
| 472 |
-- if (pSocket->pTimerSocket) |
|
| 473 |
-- {
|
|
| 474 |
-- VmSockPosixFreeSocket(pSocket->pTimerSocket); |
|
| 475 |
-- } |
|
| 476 |
- VmSockPosixFreeSocket(pSocket); |
|
| 477 |
- } |
|
| 478 |
- } |
|
| 479 |
-@@ -1118,22 +1172,21 @@ VmSockPosixCloseSocket( |
|
| 480 |
- } |
|
| 481 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 482 |
- |
|
| 483 |
-- VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Closing socket with fd %d", pSocket->fd); |
|
| 484 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Closing socket with fd %d, Socket Type %u ( 2-Io / 5-Timer )", pSocket->fd, pSocket->type); |
|
| 485 |
- |
|
| 486 |
- dwError = VmRESTLockMutex(pSocket->pMutex); |
|
| 487 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 488 |
- |
|
| 489 |
- bLocked = TRUE; |
|
| 490 |
- |
|
| 491 |
-- if (pSocket->pTimerSocket && (pSocket->pTimerSocket->fd > 0)) |
|
| 492 |
-+ if (pSocket->pTimerSocket) |
|
| 493 |
- {
|
|
| 494 |
-- close(pSocket->pTimerSocket->fd); |
|
| 495 |
-- pSocket->pTimerSocket->fd = -1; |
|
| 496 |
-+ pSocket->pTimerSocket->pIoSocket = NULL; |
|
| 497 |
- } |
|
| 498 |
- |
|
| 499 |
-- if (pRESTHandle->pSSLInfo->isSecure && pSocket->ssl) |
|
| 500 |
-+ if (pRESTHandle->pSSLInfo->isSecure && pSocket->ssl && (pSocket->type != VM_SOCK_TYPE_TIMER)) |
|
| 501 |
- {
|
|
| 502 |
-- ret = SSL_shutdown(pSocket->ssl); |
|
| 503 |
-+ ret = SSL_shutdown(pSocket->ssl); |
|
| 504 |
- if (ret < 0) |
|
| 505 |
- {
|
|
| 506 |
- errorCode = SSL_get_error(pSocket->ssl, ret); |
|
| 507 |
-@@ -1149,7 +1202,6 @@ VmSockPosixCloseSocket( |
|
| 508 |
- pSocket->fd = -1; |
|
| 509 |
- } |
|
| 510 |
- |
|
| 511 |
-- |
|
| 512 |
- cleanup: |
|
| 513 |
- |
|
| 514 |
- if (bLocked) |
|
| 515 |
-@@ -1294,6 +1346,12 @@ VmSockPosixEventQueueDelete_inlock( |
|
| 516 |
- DWORD dwError = REST_ENGINE_SUCCESS; |
|
| 517 |
- struct epoll_event event = {0};
|
|
| 518 |
- |
|
| 519 |
-+ if (!pSocket || !pQueue) |
|
| 520 |
-+ {
|
|
| 521 |
-+ dwError = REST_ERROR_INVALID_HANDLER; |
|
| 522 |
-+ } |
|
| 523 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 524 |
-+ |
|
| 525 |
- if (epoll_ctl(pQueue->epollFd, EPOLL_CTL_DEL, pSocket->fd, &event) < 0) |
|
| 526 |
- {
|
|
| 527 |
- dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 528 |
-@@ -1341,6 +1399,7 @@ VmSockPosixAcceptConnection( |
|
| 529 |
- pSocket->pTimerSocket = NULL; |
|
| 530 |
- pSocket->pIoSocket = NULL; |
|
| 531 |
- pSocket->bSSLHandShakeCompleted = FALSE; |
|
| 532 |
-+ pSocket->bInUse = FALSE; |
|
| 533 |
- |
|
| 534 |
- *ppSocket = pSocket; |
|
| 535 |
- |
|
| 536 |
-@@ -1560,35 +1619,21 @@ VmSockPosixSetRequestHandle( |
|
| 537 |
- |
|
| 538 |
- pSocket->nProcessed = nProcessed; |
|
| 539 |
- |
|
| 540 |
-- /**** Rearm timer and add sockfd back to poller ****/ |
|
| 541 |
-- if (!bCompleted) |
|
| 542 |
-+ if (bCompleted) |
|
| 543 |
- {
|
|
| 544 |
-- dwError = VmSockPosixReArmTimer( |
|
| 545 |
-- pRESTHandle, |
|
| 546 |
-- pSocket->pTimerSocket, |
|
| 547 |
-- ((pRESTHandle->pRESTConfig->connTimeoutSec) * 1000) |
|
| 548 |
-- ); |
|
| 549 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 550 |
-- |
|
| 551 |
-- event.data.ptr = pSocket; |
|
| 552 |
-- event.events = EPOLLIN; |
|
| 553 |
-- |
|
| 554 |
-- event.events = event.events | EPOLLONESHOT; |
|
| 555 |
-- |
|
| 556 |
-- if (epoll_ctl(pQueue->epollFd, EPOLL_CTL_MOD, pSocket->fd, &event) < 0) |
|
| 557 |
-+ /**** We are done with request - no need to add back to poller *****/ |
|
| 558 |
-+ if (pSocket->pTimerSocket != NULL) |
|
| 559 |
- {
|
|
| 560 |
-- dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 561 |
-+ pSocket->pTimerSocket->pIoSocket = NULL; |
|
| 562 |
-+ |
|
| 563 |
-+ /**** Give immediate notification to timer for cleanup ****/ |
|
| 564 |
-+ dwError = VmSockPosixReArmTimer( |
|
| 565 |
-+ pRESTHandle, |
|
| 566 |
-+ pSocket->pTimerSocket, |
|
| 567 |
-+ 1 |
|
| 568 |
-+ ); |
|
| 569 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 570 |
- } |
|
| 571 |
-- } |
|
| 572 |
-- else |
|
| 573 |
-- {
|
|
| 574 |
-- /**** Delete timerfd from poller ****/ |
|
| 575 |
-- dwError = VmSockPosixEventQueueDelete_inlock( |
|
| 576 |
-- pQueue, |
|
| 577 |
-- pSocket->pTimerSocket |
|
| 578 |
-- ); |
|
| 579 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 580 |
- |
|
| 581 |
- /**** Delete actual IO socket from poller ****/ |
|
| 582 |
- dwError = VmSockPosixEventQueueDelete_inlock( |
|
| 583 |
-@@ -1596,13 +1641,37 @@ VmSockPosixSetRequestHandle( |
|
| 584 |
- pSocket |
|
| 585 |
- ); |
|
| 586 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 587 |
-- |
|
| 588 |
-- |
|
| 589 |
-- if (pSocket->pTimerSocket->fd > 0) |
|
| 590 |
-+ } |
|
| 591 |
-+ else |
|
| 592 |
-+ {
|
|
| 593 |
-+ /***** Add back IO socket to poller for next IO cycle ****/ |
|
| 594 |
-+ if (pSocket->pTimerSocket == NULL) |
|
| 595 |
- {
|
|
| 596 |
-- close(pSocket->pTimerSocket->fd); |
|
| 597 |
-- pSocket->pTimerSocket->fd = -1; |
|
| 598 |
-- } |
|
| 599 |
-+ /**** Timeout already happened. Notify HTTP layer to send 408 Req timeout - if possible ****/ |
|
| 600 |
-+ dwError = VMREST_TRANSPORT_DEFERRED_TIMEOUT_PROCESS; |
|
| 601 |
-+ } |
|
| 602 |
-+ else |
|
| 603 |
-+ {
|
|
| 604 |
-+ /*** Rearm timer and add IO socket to poller ****/ |
|
| 605 |
-+ dwError = VmSockPosixReArmTimer( |
|
| 606 |
-+ pRESTHandle, |
|
| 607 |
-+ pSocket->pTimerSocket, |
|
| 608 |
-+ ((pRESTHandle->pRESTConfig->connTimeoutSec) * 1000) |
|
| 609 |
-+ ); |
|
| 610 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 611 |
-+ |
|
| 612 |
-+ event.data.ptr = pSocket; |
|
| 613 |
-+ event.events = EPOLLIN; |
|
| 614 |
-+ |
|
| 615 |
-+ event.events = event.events | EPOLLONESHOT; |
|
| 616 |
-+ |
|
| 617 |
-+ if (epoll_ctl(pQueue->epollFd, EPOLL_CTL_MOD, pSocket->fd, &event) < 0) |
|
| 618 |
-+ {
|
|
| 619 |
-+ dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 620 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 621 |
-+ } |
|
| 622 |
-+ } |
|
| 623 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 624 |
- } |
|
| 625 |
- |
|
| 626 |
- cleanup: |
|
| 627 |
-@@ -1611,6 +1680,10 @@ VmSockPosixSetRequestHandle( |
|
| 628 |
- {
|
|
| 629 |
- VmRESTUnlockMutex(pSocket->pMutex); |
|
| 630 |
- } |
|
| 631 |
-+ if (!bCompleted && pSocket && (pSocket->pTimerSocket != NULL)) |
|
| 632 |
-+ {
|
|
| 633 |
-+ pSocket->bInUse = FALSE; |
|
| 634 |
-+ } |
|
| 635 |
- |
|
| 636 |
- return dwError; |
|
| 637 |
- |
|
| 638 |
-@@ -1702,6 +1775,13 @@ VmSockPosixReArmTimer( |
|
| 639 |
- int nSec = 0; |
|
| 640 |
- int nNanoSec = 0; |
|
| 641 |
- |
|
| 642 |
-+ if (!pRESTHandle || !pTimerSocket ) |
|
| 643 |
-+ {
|
|
| 644 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Invalid params"); |
|
| 645 |
-+ dwError = ERROR_INVALID_PARAMETER; |
|
| 646 |
-+ } |
|
| 647 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 648 |
-+ |
|
| 649 |
- if (milliSec > 0) |
|
| 650 |
- {
|
|
| 651 |
- nSec = milliSec / 1000; |
|
| 652 |
-@@ -1733,96 +1813,6 @@ VmSockPosixReArmTimer( |
|
| 653 |
- |
|
| 654 |
- } |
|
| 655 |
- |
|
| 656 |
--static |
|
| 657 |
--BOOLEAN |
|
| 658 |
--VmSockPosixIsSafeToCloseConnOnTimeOut( |
|
| 659 |
-- PVMREST_HANDLE pRESTHandle, |
|
| 660 |
-- PVM_SOCKET pTimerSocket |
|
| 661 |
-- ) |
|
| 662 |
--{
|
|
| 663 |
-- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 664 |
-- struct epoll_event event = {0};
|
|
| 665 |
-- BOOLEAN bCloseConn = FALSE; |
|
| 666 |
-- ssize_t nRead = 0; |
|
| 667 |
-- uint32_t errorCode = 0; |
|
| 668 |
-- uint64_t res = 0; |
|
| 669 |
-- char pBuf = '\0'; |
|
| 670 |
-- struct itimerspec ts = {0};
|
|
| 671 |
-- PVM_SOCKET pSocket = NULL; |
|
| 672 |
-- |
|
| 673 |
-- if (!pRESTHandle || !pTimerSocket) |
|
| 674 |
-- {
|
|
| 675 |
-- VMREST_LOG_ERROR(pRESTHandle,"%s","Invalid params"); |
|
| 676 |
-- dwError = ERROR_INVALID_PARAMETER; |
|
| 677 |
-- } |
|
| 678 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 679 |
-- |
|
| 680 |
-- pSocket = pTimerSocket->pIoSocket; |
|
| 681 |
-- errno = 0; |
|
| 682 |
-- |
|
| 683 |
-- if ((pRESTHandle->pSSLInfo->isSecure) && (pSocket->ssl)) |
|
| 684 |
-- {
|
|
| 685 |
-- nRead = SSL_read(pSocket->ssl, &pBuf, 0); |
|
| 686 |
-- errorCode = SSL_get_error(pSocket->ssl, nRead); |
|
| 687 |
-- } |
|
| 688 |
-- else if (pSocket->fd > 0) |
|
| 689 |
-- {
|
|
| 690 |
-- nRead = read(pSocket->fd, &pBuf, 0); |
|
| 691 |
-- errorCode = errno; |
|
| 692 |
-- } |
|
| 693 |
-- VMREST_LOG_DEBUG(pRESTHandle, "IO socket read bytes %d, errorCode %u, at timer expiration", nRead, errorCode); |
|
| 694 |
-- |
|
| 695 |
-- if (errorCode == EAGAIN || errorCode == EWOULDBLOCK || errorCode == SSL_ERROR_WANT_READ) |
|
| 696 |
-- {
|
|
| 697 |
-- /**** Check for preceeding reset of timer due to valid IO ****/ |
|
| 698 |
-- if (timerfd_gettime(pTimerSocket->fd, &ts) == 0) |
|
| 699 |
-- {
|
|
| 700 |
-- if ((ts.it_value.tv_sec == 0) && (ts.it_value.tv_nsec == 0)) |
|
| 701 |
-- {
|
|
| 702 |
-- /**** timer is still disarmed ****/ |
|
| 703 |
-- /**** It's safe to close connection ****/ |
|
| 704 |
-- bCloseConn = TRUE; |
|
| 705 |
-- } |
|
| 706 |
-- |
|
| 707 |
-- /**** Do a read on timer socket - dummy read ****/ |
|
| 708 |
-- do |
|
| 709 |
-- {
|
|
| 710 |
-- errorCode = 0; |
|
| 711 |
-- errno = 0; |
|
| 712 |
-- nRead = 0; |
|
| 713 |
-- nRead = read(pTimerSocket->fd, &res, sizeof(res)); |
|
| 714 |
-- errorCode = errno; |
|
| 715 |
-- res = 0; |
|
| 716 |
-- }while(nRead > 0); |
|
| 717 |
-- |
|
| 718 |
-- if (!bCloseConn) |
|
| 719 |
-- {
|
|
| 720 |
-- /**** Add timer socket back to poller ****/ |
|
| 721 |
-- event.data.ptr = pTimerSocket; |
|
| 722 |
-- event.events = EPOLLIN; |
|
| 723 |
-- event.events = event.events | EPOLLONESHOT; |
|
| 724 |
-- |
|
| 725 |
-- if (epoll_ctl(pRESTHandle->pSockContext->pEventQueue->epollFd, EPOLL_CTL_MOD, pTimerSocket->fd, &event) < 0) |
|
| 726 |
-- {
|
|
| 727 |
-- dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 728 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 729 |
-- } |
|
| 730 |
-- } |
|
| 731 |
-- } |
|
| 732 |
-- } |
|
| 733 |
-- |
|
| 734 |
--cleanup: |
|
| 735 |
-- |
|
| 736 |
-- return bCloseConn; |
|
| 737 |
-- |
|
| 738 |
--error: |
|
| 739 |
-- |
|
| 740 |
-- bCloseConn = FALSE; |
|
| 741 |
-- |
|
| 742 |
-- goto cleanup; |
|
| 743 |
-- |
|
| 744 |
--} |
|
| 745 |
-- |
|
| 746 |
- static |
|
| 747 |
- uint32_t |
|
| 748 |
- VmSockPosixCreateTimer( |
|
| 749 |
-@@ -1860,6 +1850,7 @@ VmSockPosixCreateTimer( |
|
| 750 |
- |
|
| 751 |
- pTimerSocket->type = VM_SOCK_TYPE_TIMER; |
|
| 752 |
- pTimerSocket->fd = timerFd; |
|
| 753 |
-+ pTimerSocket->bInUse = FALSE; |
|
| 754 |
- pTimerSocket->pIoSocket = pSocket; |
|
| 755 |
- pTimerSocket->pRequest = NULL; |
|
| 756 |
- pTimerSocket->pszBuffer = NULL; |
|
| 757 |
-@@ -1931,6 +1922,7 @@ VmRESTAcceptSSLContext( |
|
| 758 |
- |
|
| 759 |
- if (ret == 1) |
|
| 760 |
- {
|
|
| 761 |
-+ VMREST_LOG_DEBUG(pRESTHandle," SSL accept successful on socket %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 762 |
- pSocket->bSSLHandShakeCompleted = TRUE; |
|
| 763 |
- bReArm = TRUE; |
|
| 764 |
- } |
|
| 765 |
-@@ -1940,15 +1932,22 @@ VmRESTAcceptSSLContext( |
|
| 766 |
- pSocket->bSSLHandShakeCompleted = FALSE; |
|
| 767 |
- bReArm = TRUE; |
|
| 768 |
- } |
|
| 769 |
-+ else if ((ret == 0) && (errorCode == SSL_ERROR_SYSCALL)) |
|
| 770 |
-+ {
|
|
| 771 |
-+ VMREST_LOG_ERROR(pRESTHandle," Client closed the connection during SSL handshake, socket fd %d, ret %d, errorCode %u, errno %d", pSocket->fd, ret, errorCode, errno); |
|
| 772 |
-+ dwError = VMREST_TRANSPORT_SSL_ACCEPT_FAILED; |
|
| 773 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 774 |
-+ } |
|
| 775 |
- else |
|
| 776 |
- {
|
|
| 777 |
-- VMREST_LOG_ERROR(pRESTHandle, "SSL handshake failed...connection will be closed for socket with fd %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 778 |
-+ VMREST_LOG_ERROR(pRESTHandle, "SSL handshake failed...connection will be closed for socket with fd %d, ret %d, errorCode %u, errno %d", pSocket->fd, ret, errorCode, errno); |
|
| 779 |
- dwError = VMREST_TRANSPORT_SSL_ACCEPT_FAILED; |
|
| 780 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 781 |
- } |
|
| 782 |
- |
|
| 783 |
- if (bReArm && bWatched) |
|
| 784 |
- {
|
|
| 785 |
-+ /**** Rearm and add the socket ****/ |
|
| 786 |
- dwError = VmSockPosixReArmTimer( |
|
| 787 |
- pRESTHandle, |
|
| 788 |
- pSocket->pTimerSocket, |
|
| 789 |
-@@ -1974,13 +1973,23 @@ VmRESTAcceptSSLContext( |
|
| 790 |
- |
|
| 791 |
- error: |
|
| 792 |
- |
|
| 793 |
-- if (bWatched && pRESTHandle && pRESTHandle->pSockContext) |
|
| 794 |
-+ if (pRESTHandle && pRESTHandle->pSockContext) |
|
| 795 |
- {
|
|
| 796 |
- /**** Delete from poller ****/ |
|
| 797 |
- VmSockPosixEventQueueDelete_inlock( |
|
| 798 |
- pRESTHandle->pSockContext->pEventQueue, |
|
| 799 |
- pSocket |
|
| 800 |
- ); |
|
| 801 |
-+ |
|
| 802 |
-+ if (bWatched && pSocket && pSocket->pTimerSocket) |
|
| 803 |
-+ {
|
|
| 804 |
-+ pSocket->pTimerSocket->pIoSocket = NULL; |
|
| 805 |
-+ VmSockPosixReArmTimer( |
|
| 806 |
-+ pRESTHandle, |
|
| 807 |
-+ pSocket->pTimerSocket, |
|
| 808 |
-+ 1 |
|
| 809 |
-+ ); |
|
| 810 |
-+ } |
|
| 811 |
- } |
|
| 812 |
- |
|
| 813 |
- goto cleanup; |
|
| 814 |
-diff --git a/transport/posix/structs.h b/transport/posix/structs.h |
|
| 815 |
-index ad5563e..369cfcb 100644 |
|
| 816 |
-+++ b/transport/posix/structs.h |
|
| 817 |
-@@ -20,6 +20,7 @@ typedef struct _VM_SOCKET |
|
| 818 |
- int fd; |
|
| 819 |
- SSL* ssl; |
|
| 820 |
- BOOLEAN bSSLHandShakeCompleted; |
|
| 821 |
-+ BOOLEAN bInUse; |
|
| 822 |
- char* pszBuffer; |
|
| 823 |
- uint32_t nBufData; |
|
| 824 |
- uint32_t nProcessed; |
| 825 | 1 |
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,1294 +0,0 @@ |
| 1 |
-From e4262558a10e4470dab84d50b5f7d8d4121e8d1d Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
| 3 |
-Date: Mon, 12 Feb 2018 20:03:44 -0800 |
|
| 4 |
-Subject: [PATCH] Maintaining internal library instanse state for API safety |
|
| 5 |
- |
|
| 6 |
-Change-Id: Icf1d75eaba6d62c3486653ffa1ae7528ced620e3 |
|
| 7 |
- common/sockinterface.c | 88 +++++++++++++++-- |
|
| 8 |
- include/public/vmrest.h | 1 + |
|
| 9 |
- include/vmrestcommon.h | 16 ++- |
|
| 10 |
- include/vmsock.h | 39 ++++++-- |
|
| 11 |
- server/restengine/defines.h | 16 ++- |
|
| 12 |
- server/restengine/httpAllocStruct.c | 2 + |
|
| 13 |
- server/restengine/httpMain.c | 39 +++++--- |
|
| 14 |
- server/restengine/libmain.c | 142 ++++++++++++++++++++------- |
|
| 15 |
- transport/api/api.c | 31 +++++- |
|
| 16 |
- transport/posix/libmain.c | 5 +- |
|
| 17 |
- transport/posix/prototypes.h | 11 ++- |
|
| 18 |
- transport/posix/socket.c | 187 +++++++++++++++++++----------------- |
|
| 19 |
- 12 files changed, 414 insertions(+), 163 deletions(-) |
|
| 20 |
- |
|
| 21 |
-diff --git a/common/sockinterface.c b/common/sockinterface.c |
|
| 22 |
-index 9e7d404..f737f78 100644 |
|
| 23 |
-+++ b/common/sockinterface.c |
|
| 24 |
-@@ -71,6 +71,40 @@ VmRESTInitProtocolServer( |
|
| 25 |
- ) |
|
| 26 |
- {
|
|
| 27 |
- DWORD dwError = REST_ENGINE_SUCCESS; |
|
| 28 |
-+ |
|
| 29 |
-+ if (!pRESTHandle) |
|
| 30 |
-+ {
|
|
| 31 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Invalid REST config"); |
|
| 32 |
-+ dwError = REST_ERROR_INVALID_HANDLER; |
|
| 33 |
-+ } |
|
| 34 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 35 |
-+ |
|
| 36 |
-+ /**** Init Logging ****/ |
|
| 37 |
-+ dwError = VmRESTLogInitialize( |
|
| 38 |
-+ pRESTHandle |
|
| 39 |
-+ ); |
|
| 40 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 41 |
-+ |
|
| 42 |
-+ /**** Init Transport ****/ |
|
| 43 |
-+ dwError = VmwSockInitialize(pRESTHandle); |
|
| 44 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 45 |
-+ |
|
| 46 |
-+cleanup: |
|
| 47 |
-+ |
|
| 48 |
-+ return dwError; |
|
| 49 |
-+ |
|
| 50 |
-+error: |
|
| 51 |
-+ |
|
| 52 |
-+ goto cleanup; |
|
| 53 |
-+ |
|
| 54 |
-+} |
|
| 55 |
-+ |
|
| 56 |
-+DWORD |
|
| 57 |
-+VmRESTStartProtocolServer( |
|
| 58 |
-+ PVMREST_HANDLE pRESTHandle |
|
| 59 |
-+ ) |
|
| 60 |
-+{
|
|
| 61 |
-+ DWORD dwError = REST_ENGINE_SUCCESS; |
|
| 62 |
- PVMREST_SOCK_CONTEXT pSockContext = NULL; |
|
| 63 |
- DWORD dwFlags = VM_SOCK_CREATE_FLAGS_REUSE_ADDR | |
|
| 64 |
- VM_SOCK_CREATE_FLAGS_NON_BLOCK; |
|
| 65 |
-@@ -92,7 +126,7 @@ VmRESTInitProtocolServer( |
|
| 66 |
- |
|
| 67 |
- /**** Handle IPv4 case ****/ |
|
| 68 |
- |
|
| 69 |
-- dwError = VmwSockOpenServer( |
|
| 70 |
-+ dwError = VmwSockStartServer( |
|
| 71 |
- pRESTHandle, |
|
| 72 |
- dwFlags | VM_SOCK_CREATE_FLAGS_TCP | |
|
| 73 |
- VM_SOCK_CREATE_FLAGS_IPV4, |
|
| 74 |
-@@ -103,7 +137,7 @@ VmRESTInitProtocolServer( |
|
| 75 |
- #ifdef AF_INET6 |
|
| 76 |
- /**** Handle IPv6 case ****/ |
|
| 77 |
- |
|
| 78 |
-- dwError = VmwSockOpenServer( |
|
| 79 |
-+ dwError = VmwSockStartServer( |
|
| 80 |
- pRESTHandle, |
|
| 81 |
- dwFlags | VM_SOCK_CREATE_FLAGS_TCP | |
|
| 82 |
- VM_SOCK_CREATE_FLAGS_IPV6, |
|
| 83 |
-@@ -122,7 +156,7 @@ VmRESTInitProtocolServer( |
|
| 84 |
- ); |
|
| 85 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 86 |
- |
|
| 87 |
-- dwError = VmwSockEventQueueAdd( |
|
| 88 |
-+ dwError = VmwSockAddEventToQueueInLock( |
|
| 89 |
- pRESTHandle, |
|
| 90 |
- pSockContext->pEventQueue, |
|
| 91 |
- pSockContext->pListenerTCP |
|
| 92 |
-@@ -132,7 +166,7 @@ VmRESTInitProtocolServer( |
|
| 93 |
- #ifdef AF_INET6 |
|
| 94 |
- if (!bNoIpV6) |
|
| 95 |
- {
|
|
| 96 |
-- dwError = VmwSockEventQueueAdd( |
|
| 97 |
-+ dwError = VmwSockAddEventToQueueInLock( |
|
| 98 |
- pRESTHandle, |
|
| 99 |
- pSockContext->pEventQueue, |
|
| 100 |
- pSockContext->pListenerTCP6 |
|
| 101 |
-@@ -194,7 +228,7 @@ VmRESTInitProtocolServer( |
|
| 102 |
- } |
|
| 103 |
- |
|
| 104 |
- uint32_t |
|
| 105 |
--VmRESTShutdownProtocolServer( |
|
| 106 |
-+VmRESTStopProtocolServer( |
|
| 107 |
- PVMREST_HANDLE pRESTHandle, |
|
| 108 |
- uint32_t waitSecond |
|
| 109 |
- ) |
|
| 110 |
-@@ -221,6 +255,18 @@ VmRESTShutdownProtocolServer( |
|
| 111 |
- |
|
| 112 |
- } |
|
| 113 |
- |
|
| 114 |
-+void |
|
| 115 |
-+VmRESTShutdownProtocolServer( |
|
| 116 |
-+ PVMREST_HANDLE pRESTHandle |
|
| 117 |
-+ ) |
|
| 118 |
-+{
|
|
| 119 |
-+ if (pRESTHandle) |
|
| 120 |
-+ {
|
|
| 121 |
-+ VmwSockShutdown(pRESTHandle); |
|
| 122 |
-+ VmRESTLogTerminate(pRESTHandle); |
|
| 123 |
-+ } |
|
| 124 |
-+} |
|
| 125 |
-+ |
|
| 126 |
- static |
|
| 127 |
- PVOID |
|
| 128 |
- VmRESTSockWorkerThreadProc( |
|
| 129 |
-@@ -569,6 +615,34 @@ VmRESTSockContextFree( |
|
| 130 |
- {
|
|
| 131 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 132 |
- |
|
| 133 |
-+ if (!pRESTHandle || !pSockContext) |
|
| 134 |
-+ {
|
|
| 135 |
-+ dwError = ERROR_INVALID_PARAMETER; |
|
| 136 |
-+ } |
|
| 137 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 138 |
-+ |
|
| 139 |
-+ |
|
| 140 |
-+ if (pSockContext->pListenerTCP) |
|
| 141 |
-+ {
|
|
| 142 |
-+ dwError = VmwSockDeleteEventFromQueue( |
|
| 143 |
-+ pRESTHandle, |
|
| 144 |
-+ pSockContext->pEventQueue, |
|
| 145 |
-+ pSockContext->pListenerTCP |
|
| 146 |
-+ ); |
|
| 147 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 148 |
-+ VmwSockClose( pRESTHandle, pSockContext->pListenerTCP); |
|
| 149 |
-+ } |
|
| 150 |
-+ if (pSockContext->pListenerTCP6) |
|
| 151 |
-+ {
|
|
| 152 |
-+ dwError = VmwSockDeleteEventFromQueue( |
|
| 153 |
-+ pRESTHandle, |
|
| 154 |
-+ pSockContext->pEventQueue, |
|
| 155 |
-+ pSockContext->pListenerTCP6 |
|
| 156 |
-+ ); |
|
| 157 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 158 |
-+ VmwSockClose( pRESTHandle, pSockContext->pListenerTCP6); |
|
| 159 |
-+ } |
|
| 160 |
-+ |
|
| 161 |
- if (pSockContext->pEventQueue) |
|
| 162 |
- {
|
|
| 163 |
- dwError = VmwSockCloseEventQueue(pRESTHandle, pSockContext->pEventQueue, waitSecond); |
|
| 164 |
-@@ -577,14 +651,14 @@ VmRESTSockContextFree( |
|
| 165 |
- |
|
| 166 |
- if (pSockContext->pListenerTCP) |
|
| 167 |
- {
|
|
| 168 |
-- VmwSockClose( pRESTHandle, pSockContext->pListenerTCP); |
|
| 169 |
- VmwSockRelease( pRESTHandle, pSockContext->pListenerTCP); |
|
| 170 |
- } |
|
| 171 |
-+ |
|
| 172 |
- if (pSockContext->pListenerTCP6) |
|
| 173 |
- {
|
|
| 174 |
-- VmwSockClose( pRESTHandle, pSockContext->pListenerTCP6); |
|
| 175 |
- VmwSockRelease( pRESTHandle, pSockContext->pListenerTCP6); |
|
| 176 |
- } |
|
| 177 |
-+ |
|
| 178 |
- if (pSockContext->pWorkerThreads) |
|
| 179 |
- {
|
|
| 180 |
- DWORD iThr = 0; |
|
| 181 |
-diff --git a/include/public/vmrest.h b/include/public/vmrest.h |
|
| 182 |
-index 5219952..6ebe3fd 100644 |
|
| 183 |
-+++ b/include/public/vmrest.h |
|
| 184 |
-@@ -46,6 +46,7 @@ |
|
| 185 |
- #define REST_ERROR_BAD_CONFIG_FILE_PATH 110 |
|
| 186 |
- #define REST_ERROR_PREV_INSTANCE_NOT_CLEAN 111 |
|
| 187 |
- #define REST_ERROR_INVALID_HANDLER 112 |
|
| 188 |
-+#define REST_ENGINE_ERROR_INVALID_PARAM 112 |
|
| 189 |
- #define REST_ENGINE_SSL_CONFIG_FILE 113 |
|
| 190 |
- #define REST_ENGINE_NO_DEBUG_LOGGING 114 |
|
| 191 |
- #define REST_ENGINE_BAD_LOG_LEVEL 115 |
|
| 192 |
-diff --git a/include/vmrestcommon.h b/include/vmrestcommon.h |
|
| 193 |
-index d966f0e..3b7f17c 100644 |
|
| 194 |
-+++ b/include/vmrestcommon.h |
|
| 195 |
-@@ -260,14 +260,14 @@ typedef struct _REST_ENG_GLOBALS *PREST_ENG_GLOBALS; |
|
| 196 |
- typedef struct _VMREST_HANDLE |
|
| 197 |
- {
|
|
| 198 |
- int debugLogLevel; |
|
| 199 |
-+ int instanceState; |
|
| 200 |
- FILE* logFile; |
|
| 201 |
- PVM_SOCK_PACKAGE pPackage; |
|
| 202 |
- PVM_SOCK_SSL_INFO pSSLInfo; |
|
| 203 |
- PREST_PROCESSOR pHttpHandler; |
|
| 204 |
- PREST_ENG_GLOBALS pInstanceGlobal; |
|
| 205 |
- PVMREST_SOCK_CONTEXT pSockContext; |
|
| 206 |
-- PVM_REST_CONFIG pRESTConfig; |
|
| 207 |
-- |
|
| 208 |
-+ PVM_REST_CONFIG pRESTConfig; |
|
| 209 |
- } VMREST_HANDLE; |
|
| 210 |
- |
|
| 211 |
- typedef struct _VM_WORKER_THREAD_DATA |
|
| 212 |
-@@ -296,11 +296,21 @@ VmRESTInitProtocolServer( |
|
| 213 |
- ); |
|
| 214 |
- |
|
| 215 |
- DWORD |
|
| 216 |
--VmRESTShutdownProtocolServer( |
|
| 217 |
-+VmRESTStartProtocolServer( |
|
| 218 |
-+ PVMREST_HANDLE pRESTHandle |
|
| 219 |
-+ ); |
|
| 220 |
-+ |
|
| 221 |
-+DWORD |
|
| 222 |
-+VmRESTStopProtocolServer( |
|
| 223 |
- PVMREST_HANDLE pRESTHandle, |
|
| 224 |
- uint32_t waitSecond |
|
| 225 |
- ); |
|
| 226 |
- |
|
| 227 |
-+VOID |
|
| 228 |
-+VmRESTShutdownProtocolServer( |
|
| 229 |
-+ PVMREST_HANDLE pRESTHandle |
|
| 230 |
-+ ); |
|
| 231 |
-+ |
|
| 232 |
- uint32_t |
|
| 233 |
- VmRESTCommonWriteDataAtOnce( |
|
| 234 |
- PVMREST_HANDLE pRESTHandle, |
|
| 235 |
-diff --git a/include/vmsock.h b/include/vmsock.h |
|
| 236 |
-index 7b60b29..5075aa7 100644 |
|
| 237 |
-+++ b/include/vmsock.h |
|
| 238 |
-@@ -87,7 +87,7 @@ VmwSockInitialize( |
|
| 239 |
- ); |
|
| 240 |
- |
|
| 241 |
- /** |
|
| 242 |
-- * @brief Opens a server socket |
|
| 243 |
-+ * @brief Starts a server socket |
|
| 244 |
- * |
|
| 245 |
- * @param[in] Handle to library instance. |
|
| 246 |
- * @param[in] dwFlags 32 bit flags defining socket creation preferences |
|
| 247 |
-@@ -96,7 +96,7 @@ VmwSockInitialize( |
|
| 248 |
- * @return 0 on success |
|
| 249 |
- */ |
|
| 250 |
- DWORD |
|
| 251 |
--VmwSockOpenServer( |
|
| 252 |
-+VmwSockStartServer( |
|
| 253 |
- PVMREST_HANDLE pRESTHandle, |
|
| 254 |
- VM_SOCK_CREATE_FLAGS dwFlags, |
|
| 255 |
- PVM_SOCKET* ppSocket |
|
| 256 |
-@@ -117,7 +117,7 @@ VmwSockCreateEventQueue( |
|
| 257 |
- ); |
|
| 258 |
- |
|
| 259 |
- /** |
|
| 260 |
-- * @brief Adds a socket to the event queue |
|
| 261 |
-+ * @brief Add a socket to the event queue |
|
| 262 |
- * |
|
| 263 |
- * @param[in] Handle to library instance. |
|
| 264 |
- * @param[in] pQueue Pointer to Event queue |
|
| 265 |
-@@ -126,7 +126,23 @@ VmwSockCreateEventQueue( |
|
| 266 |
- * @return 0 on success |
|
| 267 |
- */ |
|
| 268 |
- DWORD |
|
| 269 |
--VmwSockEventQueueAdd( |
|
| 270 |
-+VmwSockAddEventToQueueInLock( |
|
| 271 |
-+ PVMREST_HANDLE pRESTHandle, |
|
| 272 |
-+ PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 273 |
-+ PVM_SOCKET pSocket |
|
| 274 |
-+ ); |
|
| 275 |
-+ |
|
| 276 |
-+/** |
|
| 277 |
-+ * @brief Deletes a socket from the event queue |
|
| 278 |
-+ * |
|
| 279 |
-+ * @param[in] Handle to library instance. |
|
| 280 |
-+ * @param[in] pQueue Pointer to Event queue |
|
| 281 |
-+ * @param[in] pSocket Pointer to Socket |
|
| 282 |
-+ * |
|
| 283 |
-+ * @return 0 on success |
|
| 284 |
-+ */ |
|
| 285 |
-+DWORD |
|
| 286 |
-+VmwSockDeleteEventFromQueue( |
|
| 287 |
- PVMREST_HANDLE pRESTHandle, |
|
| 288 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 289 |
- PVM_SOCKET pSocket |
|
| 290 |
-@@ -280,7 +296,7 @@ typedef enum |
|
| 291 |
- VM_SOCK_TYPE_TCP_V6 |
|
| 292 |
- } VM_SOCK_TYPE; |
|
| 293 |
- |
|
| 294 |
--typedef DWORD (*PFN_OPEN_SERVER_SOCKET)( |
|
| 295 |
-+typedef DWORD (*PFN_START_SERVER_SOCKET)( |
|
| 296 |
- PVMREST_HANDLE pRESTHandle, |
|
| 297 |
- VM_SOCK_CREATE_FLAGS dwFlags, |
|
| 298 |
- PVM_SOCKET* ppSocket |
|
| 299 |
-@@ -291,7 +307,13 @@ typedef DWORD (*PFN_CREATE_EVENT_QUEUE)( |
|
| 300 |
- PVM_SOCK_EVENT_QUEUE* ppQueue |
|
| 301 |
- ); |
|
| 302 |
- |
|
| 303 |
--typedef DWORD (*PFN_ADD_EVENT_QUEUE)( |
|
| 304 |
-+typedef DWORD (*PFN_ADD_EVENT_TO_QUEUE)( |
|
| 305 |
-+ PVMREST_HANDLE pRESTHandle, |
|
| 306 |
-+ PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 307 |
-+ PVM_SOCKET pSocket |
|
| 308 |
-+ ); |
|
| 309 |
-+ |
|
| 310 |
-+typedef DWORD (*PFN_DELETE_EVENT_FROM_QUEUE)( |
|
| 311 |
- PVMREST_HANDLE pRESTHandle, |
|
| 312 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 313 |
- PVM_SOCKET pSocket |
|
| 314 |
-@@ -359,9 +381,10 @@ typedef DWORD(*PFN_GET_PEER_INFO)( |
|
| 315 |
- |
|
| 316 |
- typedef struct _VM_SOCK_PACKAGE |
|
| 317 |
- {
|
|
| 318 |
-- PFN_OPEN_SERVER_SOCKET pfnOpenServerSocket; |
|
| 319 |
-+ PFN_START_SERVER_SOCKET pfnStartServerSocket; |
|
| 320 |
- PFN_CREATE_EVENT_QUEUE pfnCreateEventQueue; |
|
| 321 |
-- PFN_ADD_EVENT_QUEUE pfnAddEventQueue; |
|
| 322 |
-+ PFN_ADD_EVENT_TO_QUEUE pfnAddEventToQueue; |
|
| 323 |
-+ PFN_DELETE_EVENT_FROM_QUEUE pfnDeleteEventFromQueue; |
|
| 324 |
- PFN_WAIT_FOR_EVENT pfnWaitForEvent; |
|
| 325 |
- PFN_CLOSE_EVENT_QUEUE pfnCloseEventQueue; |
|
| 326 |
- PFN_READ pfnRead; |
|
| 327 |
-diff --git a/server/restengine/defines.h b/server/restengine/defines.h |
|
| 328 |
-index 380af9c..ec1e542 100644 |
|
| 329 |
-+++ b/server/restengine/defines.h |
|
| 330 |
-@@ -17,11 +17,12 @@ typedef void* (PFN_VMREST_THR_ROUTINE)(void*); |
|
| 331 |
- |
|
| 332 |
- /* HTTP protocol header defines */ |
|
| 333 |
- |
|
| 334 |
--#define MAX_METHOD_LEN 10 |
|
| 335 |
--#define MAX_URI_LEN 10240 |
|
| 336 |
-+#define MAX_METHOD_LEN 10 |
|
| 337 |
-+#define MAX_URI_LEN 10240 |
|
| 338 |
- #define MAX_VERSION_LEN 9 |
|
| 339 |
- #define MAX_STATUS_LEN 4 |
|
| 340 |
--#define MAX_REA_PHRASE_LEN 32 |
|
| 341 |
-+#define MAX_REA_PHRASE_LEN 32 |
|
| 342 |
-+#define MAX_STOP_WAIT_SECONDS 600 |
|
| 343 |
- #define HTTP_VER_LEN 8 |
|
| 344 |
- #define HTTP_CHUNK_DATA_MIN_LEN 3 |
|
| 345 |
- #define HTTP_CHUNKED_DATA_LEN 8 |
|
| 346 |
-@@ -62,6 +63,15 @@ typedef enum _HTTP_PAYLOAD_TYPE |
|
| 347 |
- HTTP_PAYLOAD_TRANSFER_ENCODING |
|
| 348 |
- }HTTP_PAYLOAD_TYPE; |
|
| 349 |
- |
|
| 350 |
-+typedef enum _VM_REST_INSTANCE_STATE |
|
| 351 |
-+{
|
|
| 352 |
-+ VMREST_INSTANCE_UNINITIALIZED = -1, |
|
| 353 |
-+ VMREST_INSTANCE_INITIALIZED = 1, |
|
| 354 |
-+ VMREST_INSTANCE_STARTED = 2, |
|
| 355 |
-+ VMREST_INSTANCE_STOPPED = 3, |
|
| 356 |
-+ VMREST_INSTANCE_SHUTDOWN = 4 |
|
| 357 |
-+}VM_REST_INSTANCE_STATE; |
|
| 358 |
-+ |
|
| 359 |
- typedef enum _VM_REST_PROCESSING_STATE |
|
| 360 |
- {
|
|
| 361 |
- PROCESS_INVALID = -1, |
|
| 362 |
-diff --git a/server/restengine/httpAllocStruct.c b/server/restengine/httpAllocStruct.c |
|
| 363 |
-index 27aa9ed..18a016e 100644 |
|
| 364 |
-+++ b/server/restengine/httpAllocStruct.c |
|
| 365 |
-@@ -345,6 +345,8 @@ VmRESTAllocateHandle( |
|
| 366 |
- |
|
| 367 |
- pRESTHandle->pHttpHandler = NULL; |
|
| 368 |
- |
|
| 369 |
-+ pRESTHandle->instanceState = VMREST_INSTANCE_UNINITIALIZED; |
|
| 370 |
-+ |
|
| 371 |
- *ppRESTHandle = pRESTHandle; |
|
| 372 |
- |
|
| 373 |
- cleanup: |
|
| 374 |
-diff --git a/server/restengine/httpMain.c b/server/restengine/httpMain.c |
|
| 375 |
-index 562a555..9f3afcd 100644 |
|
| 376 |
-+++ b/server/restengine/httpMain.c |
|
| 377 |
-@@ -23,7 +23,6 @@ VmHTTPInit( |
|
| 378 |
- |
|
| 379 |
- if (!pRESTHandle || !pConfig) |
|
| 380 |
- {
|
|
| 381 |
-- VMREST_LOG_DEBUG(pRESTHandle,"%s","Invalid params"); |
|
| 382 |
- dwError = REST_ERROR_INVALID_CONFIG; |
|
| 383 |
- } |
|
| 384 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 385 |
-@@ -41,21 +40,19 @@ VmHTTPInit( |
|
| 386 |
- ); |
|
| 387 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 388 |
- |
|
| 389 |
-- pRESTHandle->debugLogLevel = pRESTHandle->pRESTConfig->debugLogLevel; |
|
| 390 |
-- |
|
| 391 |
-- /**** Init the debug log ****/ |
|
| 392 |
-- dwError = VmRESTLogInitialize( |
|
| 393 |
-+ /**** Init logging and transport ****/ |
|
| 394 |
-+ dwError = VmRESTInitProtocolServer( |
|
| 395 |
- pRESTHandle |
|
| 396 |
- ); |
|
| 397 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 398 |
- |
|
| 399 |
-- /**** Init Transport ****/ |
|
| 400 |
-- dwError = VmwSockInitialize(pRESTHandle); |
|
| 401 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 402 |
-+ pRESTHandle->debugLogLevel = pRESTHandle->pRESTConfig->debugLogLevel; |
|
| 403 |
- |
|
| 404 |
- /**** Update context Info for this lib instance ****/ |
|
| 405 |
- pRESTHandle->pInstanceGlobal->useEndPoint = 0; |
|
| 406 |
- |
|
| 407 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s","C-REST_ENGINE: Library initialized ..."); |
|
| 408 |
-+ |
|
| 409 |
- cleanup: |
|
| 410 |
- |
|
| 411 |
- return dwError; |
|
| 412 |
-@@ -72,9 +69,13 @@ VmHTTPStart( |
|
| 413 |
- {
|
|
| 414 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 415 |
- |
|
| 416 |
-- dwError = VmRESTInitProtocolServer(pRESTHandle); |
|
| 417 |
-+ dwError = VmRESTStartProtocolServer( |
|
| 418 |
-+ pRESTHandle |
|
| 419 |
-+ ); |
|
| 420 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 421 |
- |
|
| 422 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s","C-REST_ENGINE: Library started ..."); |
|
| 423 |
-+ |
|
| 424 |
- cleanup: |
|
| 425 |
- |
|
| 426 |
- return dwError; |
|
| 427 |
-@@ -132,14 +133,22 @@ VmHTTPStop( |
|
| 428 |
- {
|
|
| 429 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 430 |
- |
|
| 431 |
-- VMREST_LOG_DEBUG(pRESTHandle,"%s","Shutting down rest engine ...."); |
|
| 432 |
-- dwError = VmRESTShutdownProtocolServer(pRESTHandle, waitSecond); |
|
| 433 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s","C-REST_ENGINE: Stopping library ... No more requests will be accepted"); |
|
| 434 |
-+ |
|
| 435 |
-+ dwError = VmRESTStopProtocolServer( |
|
| 436 |
-+ pRESTHandle, |
|
| 437 |
-+ waitSecond |
|
| 438 |
-+ ); |
|
| 439 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 440 |
- |
|
| 441 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s", "C-REST-ENGINE: Library stopped ..."); |
|
| 442 |
-+ |
|
| 443 |
- cleanup: |
|
| 444 |
-- VMREST_LOG_DEBUG(pRESTHandle,"Stop returning %u", dwError); |
|
| 445 |
-+ |
|
| 446 |
- return dwError; |
|
| 447 |
- error: |
|
| 448 |
-+ |
|
| 449 |
-+ VMREST_LOG_ERROR(pRESTHandle,"C-REST-ENGINE: Library stop failed ... Do not attempt shutdown, dwError = %u", dwError); |
|
| 450 |
- goto cleanup; |
|
| 451 |
- } |
|
| 452 |
- |
|
| 453 |
-@@ -148,11 +157,13 @@ VmHTTPShutdown( |
|
| 454 |
- PVMREST_HANDLE pRESTHandle |
|
| 455 |
- ) |
|
| 456 |
- {
|
|
| 457 |
-- VmwSockShutdown(pRESTHandle); |
|
| 458 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s","C-REST-ENGINE: Shutting down Library"); |
|
| 459 |
-+ VmRESTShutdownProtocolServer( |
|
| 460 |
-+ pRESTHandle |
|
| 461 |
-+ ); |
|
| 462 |
- |
|
| 463 |
- if (pRESTHandle) |
|
| 464 |
- {
|
|
| 465 |
-- VmRESTLogTerminate(pRESTHandle); |
|
| 466 |
- VmRESTFreeHandle(pRESTHandle); |
|
| 467 |
- } |
|
| 468 |
- } |
|
| 469 |
-diff --git a/server/restengine/libmain.c b/server/restengine/libmain.c |
|
| 470 |
-index a7b85a1..3992b76 100644 |
|
| 471 |
-+++ b/server/restengine/libmain.c |
|
| 472 |
-@@ -48,9 +48,9 @@ VmRESTInit( |
|
| 473 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 474 |
- PVMREST_HANDLE pRESTHandle = NULL; |
|
| 475 |
- |
|
| 476 |
-- if (!ppRESTHandle) |
|
| 477 |
-+ if (!pConfig || !ppRESTHandle) |
|
| 478 |
- {
|
|
| 479 |
-- dwError = REST_ERROR_INVALID_HANDLER; |
|
| 480 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 481 |
- } |
|
| 482 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 483 |
- |
|
| 484 |
-@@ -69,6 +69,8 @@ VmRESTInit( |
|
| 485 |
- ); |
|
| 486 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 487 |
- |
|
| 488 |
-+ pRESTHandle->instanceState = VMREST_INSTANCE_INITIALIZED; |
|
| 489 |
-+ |
|
| 490 |
- *ppRESTHandle = pRESTHandle; |
|
| 491 |
- |
|
| 492 |
- cleanup: |
|
| 493 |
-@@ -102,7 +104,7 @@ VmRESTSetSSLInfo( |
|
| 494 |
- |
|
| 495 |
- if (!pRESTHandle || !pDataBuffer || (bufferSize == 0) || (bufferSize > MAX_SSL_DATA_BUF_LEN) || (sslDataType < SSL_DATA_TYPE_KEY) || (sslDataType > SSL_DATA_TYPE_CERT)) |
|
| 496 |
- {
|
|
| 497 |
-- dwError = REST_ERROR_INVALID_HANDLER; |
|
| 498 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 499 |
- } |
|
| 500 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 501 |
- |
|
| 502 |
-@@ -177,9 +179,9 @@ VmRESTStart( |
|
| 503 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 504 |
- int ret = 0; |
|
| 505 |
- |
|
| 506 |
-- if (!pRESTHandle) |
|
| 507 |
-+ if (!pRESTHandle || (pRESTHandle->instanceState != VMREST_INSTANCE_INITIALIZED)) |
|
| 508 |
- {
|
|
| 509 |
-- dwError = REST_ERROR_INVALID_REST_PROCESSER; |
|
| 510 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 511 |
- } |
|
| 512 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 513 |
- |
|
| 514 |
-@@ -218,9 +220,14 @@ VmRESTStart( |
|
| 515 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 516 |
- } |
|
| 517 |
- |
|
| 518 |
-+ pRESTHandle->instanceState = VMREST_INSTANCE_STARTED; |
|
| 519 |
-+ |
|
| 520 |
- cleanup: |
|
| 521 |
-+ |
|
| 522 |
- return dwError; |
|
| 523 |
-+ |
|
| 524 |
- error: |
|
| 525 |
-+ |
|
| 526 |
- goto cleanup; |
|
| 527 |
- |
|
| 528 |
- } |
|
| 529 |
-@@ -236,9 +243,9 @@ VmRESTRegisterHandler( |
|
| 530 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 531 |
- PREST_PROCESSOR pzHandler = NULL; |
|
| 532 |
- |
|
| 533 |
-- if (!pHandler || !pRESTHandle) |
|
| 534 |
-+ if (!pHandler || !pRESTHandle || (pRESTHandle->instanceState != VMREST_INSTANCE_INITIALIZED)) |
|
| 535 |
- {
|
|
| 536 |
-- dwError = REST_ERROR_INVALID_REST_PROCESSER; |
|
| 537 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 538 |
- } |
|
| 539 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 540 |
- |
|
| 541 |
-@@ -292,6 +299,12 @@ VmRESTFindEndpoint( |
|
| 542 |
- PREST_ENDPOINT temp = NULL; |
|
| 543 |
- PREST_ENDPOINT pEndPoint = NULL; |
|
| 544 |
- |
|
| 545 |
-+ if (!pRESTHandle || !pszEndpoint || !ppEndpoint || (pRESTHandle->instanceState == VMREST_INSTANCE_UNINITIALIZED) || (pRESTHandle->instanceState == VMREST_INSTANCE_SHUTDOWN)) |
|
| 546 |
-+ {
|
|
| 547 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 548 |
-+ } |
|
| 549 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 550 |
-+ |
|
| 551 |
- dwError = VmRestEngineGetEndPoint( |
|
| 552 |
- pRESTHandle, |
|
| 553 |
- (char*)pszEndpoint, |
|
| 554 |
-@@ -329,12 +342,18 @@ VmRESTFindEndpoint( |
|
| 555 |
- uint32_t |
|
| 556 |
- VmRESTUnRegisterHandler( |
|
| 557 |
- PVMREST_HANDLE pRESTHandle, |
|
| 558 |
-- char const* pzEndPointURI |
|
| 559 |
-+ char const* pcszEndPointURI |
|
| 560 |
- ) |
|
| 561 |
- {
|
|
| 562 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 563 |
- |
|
| 564 |
-- if (!pzEndPointURI) |
|
| 565 |
-+ if (!pRESTHandle || !pcszEndPointURI || (pRESTHandle->instanceState != VMREST_INSTANCE_STOPPED)) |
|
| 566 |
-+ {
|
|
| 567 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 568 |
-+ } |
|
| 569 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 570 |
-+ |
|
| 571 |
-+ if (!pcszEndPointURI) |
|
| 572 |
- {
|
|
| 573 |
- /**** Interacting with HTTP directly ****/ |
|
| 574 |
- dwError = VmHTTPUnRegisterHandler( |
|
| 575 |
-@@ -346,7 +365,7 @@ VmRESTUnRegisterHandler( |
|
| 576 |
- /**** Endpoint based library instance ****/ |
|
| 577 |
- dwError = VmRestEngineRemoveEndpoint( |
|
| 578 |
- pRESTHandle, |
|
| 579 |
-- pzEndPointURI |
|
| 580 |
-+ pcszEndPointURI |
|
| 581 |
- ); |
|
| 582 |
- } |
|
| 583 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 584 |
-@@ -365,12 +384,14 @@ VmRESTStop( |
|
| 585 |
- {
|
|
| 586 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 587 |
- |
|
| 588 |
-- if (!pRESTHandle) |
|
| 589 |
-+ if (!pRESTHandle || (waitSeconds > MAX_STOP_WAIT_SECONDS) || (pRESTHandle->instanceState != VMREST_INSTANCE_STARTED)) |
|
| 590 |
- {
|
|
| 591 |
-- dwError = REST_ERROR_INVALID_HANDLER; |
|
| 592 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 593 |
- } |
|
| 594 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 595 |
- |
|
| 596 |
-+ pRESTHandle->instanceState = VMREST_INSTANCE_STOPPED; |
|
| 597 |
-+ |
|
| 598 |
- dwError = VmHTTPStop( |
|
| 599 |
- pRESTHandle, |
|
| 600 |
- waitSeconds |
|
| 601 |
-@@ -388,14 +409,18 @@ VmRESTShutdown( |
|
| 602 |
- PVMREST_HANDLE pRESTHandle |
|
| 603 |
- ) |
|
| 604 |
- {
|
|
| 605 |
-- if (pRESTHandle->pInstanceGlobal->useEndPoint == 1) |
|
| 606 |
-+ if (pRESTHandle && (pRESTHandle->instanceState == VMREST_INSTANCE_STOPPED)) |
|
| 607 |
- {
|
|
| 608 |
-- VmRestEngineShutdownEndPointRegistration( |
|
| 609 |
-- pRESTHandle |
|
| 610 |
-- ); |
|
| 611 |
-+ pRESTHandle->instanceState = VMREST_INSTANCE_SHUTDOWN; |
|
| 612 |
-+ if (pRESTHandle->pInstanceGlobal->useEndPoint == 1) |
|
| 613 |
-+ {
|
|
| 614 |
-+ VmRestEngineShutdownEndPointRegistration( |
|
| 615 |
-+ pRESTHandle |
|
| 616 |
-+ ); |
|
| 617 |
-+ } |
|
| 618 |
-+ |
|
| 619 |
-+ VmHTTPShutdown(pRESTHandle); |
|
| 620 |
- } |
|
| 621 |
-- |
|
| 622 |
-- VmHTTPShutdown(pRESTHandle); |
|
| 623 |
- } |
|
| 624 |
- |
|
| 625 |
- uint32_t |
|
| 626 |
-@@ -408,14 +433,28 @@ VmRESTGetData( |
|
| 627 |
- {
|
|
| 628 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 629 |
- |
|
| 630 |
-+ if (!pRESTHandle || (pRESTHandle->instanceState != VMREST_INSTANCE_STARTED)) |
|
| 631 |
-+ {
|
|
| 632 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 633 |
-+ } |
|
| 634 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 635 |
-+ |
|
| 636 |
- dwError = VmRESTGetHttpPayload( |
|
| 637 |
- pRESTHandle, |
|
| 638 |
- pRequest, |
|
| 639 |
- pBuffer, |
|
| 640 |
- bytesRead |
|
| 641 |
- ); |
|
| 642 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 643 |
- |
|
| 644 |
-+cleanup: |
|
| 645 |
-+ |
|
| 646 |
- return dwError; |
|
| 647 |
-+ |
|
| 648 |
-+error: |
|
| 649 |
-+ |
|
| 650 |
-+ goto cleanup; |
|
| 651 |
-+ |
|
| 652 |
- } |
|
| 653 |
- |
|
| 654 |
- /*** GetData Zero copy API ****/ |
|
| 655 |
-@@ -427,14 +466,12 @@ VmRESTGetDataZC( |
|
| 656 |
- uint32_t* nBytes |
|
| 657 |
- ) |
|
| 658 |
- {
|
|
| 659 |
-- |
|
| 660 |
-- |
|
| 661 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 662 |
- |
|
| 663 |
-- if (!pRESTHandle || !pRequest || !ppBuffer || !nBytes) |
|
| 664 |
-+ if (!pRESTHandle || !pRequest || !ppBuffer || !nBytes || (pRESTHandle->instanceState != VMREST_INSTANCE_STARTED)) |
|
| 665 |
- {
|
|
| 666 |
- VMREST_LOG_ERROR(pRESTHandle,"%s","Invalid params"); |
|
| 667 |
-- dwError = VMREST_HTTP_INVALID_PARAMS; |
|
| 668 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 669 |
- } |
|
| 670 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 671 |
- |
|
| 672 |
-@@ -463,23 +500,38 @@ uint32_t |
|
| 673 |
- VmRESTSetData( |
|
| 674 |
- PVMREST_HANDLE pRESTHandle, |
|
| 675 |
- PREST_RESPONSE* ppResponse, |
|
| 676 |
-- char const* buffer, |
|
| 677 |
-+ char const* pcszBuffer, |
|
| 678 |
- uint32_t dataLen, |
|
| 679 |
- uint32_t* bytesWritten |
|
| 680 |
- ) |
|
| 681 |
- {
|
|
| 682 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 683 |
- |
|
| 684 |
-+ |
|
| 685 |
-+ if (!pRESTHandle || !ppResponse || !pcszBuffer || !bytesWritten || (pRESTHandle->instanceState != VMREST_INSTANCE_STARTED)) |
|
| 686 |
-+ {
|
|
| 687 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Invalid params"); |
|
| 688 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 689 |
-+ } |
|
| 690 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 691 |
-+ |
|
| 692 |
- dwError = VmRESTSetHttpPayload( |
|
| 693 |
- pRESTHandle, |
|
| 694 |
- ppResponse, |
|
| 695 |
-- buffer, |
|
| 696 |
-+ pcszBuffer, |
|
| 697 |
- dataLen, |
|
| 698 |
- bytesWritten |
|
| 699 |
- ); |
|
| 700 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 701 |
-+ |
|
| 702 |
-+cleanup: |
|
| 703 |
- |
|
| 704 |
- return dwError; |
|
| 705 |
- |
|
| 706 |
-+error: |
|
| 707 |
-+ |
|
| 708 |
-+ goto cleanup; |
|
| 709 |
-+ |
|
| 710 |
- } |
|
| 711 |
- |
|
| 712 |
- /**** SetData Zero Copy API ****/ |
|
| 713 |
-@@ -487,21 +539,37 @@ uint32_t |
|
| 714 |
- VmRESTSetDataZC( |
|
| 715 |
- PVMREST_HANDLE pRESTHandle, |
|
| 716 |
- PREST_RESPONSE* ppResponse, |
|
| 717 |
-- char const* pBuffer, |
|
| 718 |
-+ char const* pcszBuffer, |
|
| 719 |
- uint32_t nBytes |
|
| 720 |
- ) |
|
| 721 |
- {
|
|
| 722 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 723 |
- |
|
| 724 |
-+ |
|
| 725 |
-+ if (!pRESTHandle || !ppResponse || !pcszBuffer || (pRESTHandle->instanceState != VMREST_INSTANCE_STARTED)) |
|
| 726 |
-+ {
|
|
| 727 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Invalid params"); |
|
| 728 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 729 |
-+ } |
|
| 730 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 731 |
-+ |
|
| 732 |
-+ |
|
| 733 |
- dwError = VmRESTSetHttpPayloadZeroCopy( |
|
| 734 |
- pRESTHandle, |
|
| 735 |
- ppResponse, |
|
| 736 |
-- pBuffer, |
|
| 737 |
-+ pcszBuffer, |
|
| 738 |
- nBytes |
|
| 739 |
- ); |
|
| 740 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 741 |
-+ |
|
| 742 |
-+cleanup: |
|
| 743 |
- |
|
| 744 |
- return dwError; |
|
| 745 |
- |
|
| 746 |
-+error: |
|
| 747 |
-+ |
|
| 748 |
-+ goto cleanup; |
|
| 749 |
-+ |
|
| 750 |
- } |
|
| 751 |
- |
|
| 752 |
- uint32_t |
|
| 753 |
-@@ -513,6 +581,12 @@ VmRESTSetSuccessResponse( |
|
| 754 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 755 |
- char* connection = NULL; |
|
| 756 |
- |
|
| 757 |
-+ if (!pRequest || !ppResponse) |
|
| 758 |
-+ {
|
|
| 759 |
-+ dwError = REST_ENGINE_ERROR_INVALID_PARAM; |
|
| 760 |
-+ } |
|
| 761 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 762 |
-+ |
|
| 763 |
- dwError = VmRESTSetHttpStatusCode( |
|
| 764 |
- ppResponse, |
|
| 765 |
- "200" |
|
| 766 |
-@@ -571,8 +645,8 @@ VmRESTSetSuccessResponse( |
|
| 767 |
- uint32_t |
|
| 768 |
- VmRESTSetFailureResponse( |
|
| 769 |
- PREST_RESPONSE* ppResponse, |
|
| 770 |
-- char const* pErrorCode, |
|
| 771 |
-- char const* pErrorMessage |
|
| 772 |
-+ char const* pcszErrorCode, |
|
| 773 |
-+ char const* pcszErrorMessage |
|
| 774 |
- ) |
|
| 775 |
- {
|
|
| 776 |
- uint32_t dwError = REST_ENGINE_SUCCESS; |
|
| 777 |
-@@ -584,22 +658,22 @@ VmRESTSetFailureResponse( |
|
| 778 |
- |
|
| 779 |
- /**** If error code and message is not provided, send internal server error ****/ |
|
| 780 |
- |
|
| 781 |
-- if (!pErrorCode) |
|
| 782 |
-+ if (!pcszErrorCode) |
|
| 783 |
- {
|
|
| 784 |
- strcpy(errorCode,"500"); |
|
| 785 |
- } |
|
| 786 |
-- else if ((strlen(pErrorCode) > 0) && (strlen(pErrorCode) <= MAX_STATUS_LEN)) |
|
| 787 |
-+ else if ((strlen(pcszErrorCode) > 0) && (strlen(pcszErrorCode) <= MAX_STATUS_LEN)) |
|
| 788 |
- {
|
|
| 789 |
-- strcpy(errorCode, pErrorCode); |
|
| 790 |
-+ strcpy(errorCode, pcszErrorCode); |
|
| 791 |
- } |
|
| 792 |
- |
|
| 793 |
-- if (!pErrorMessage) |
|
| 794 |
-+ if (!pcszErrorMessage) |
|
| 795 |
- {
|
|
| 796 |
- strcpy(errorMessage, "Internal Server Error"); |
|
| 797 |
- } |
|
| 798 |
-- else if ((strlen(pErrorMessage) > 0) && (strlen(pErrorMessage) <= MAX_REA_PHRASE_LEN)) |
|
| 799 |
-+ else if ((strlen(pcszErrorMessage) > 0) && (strlen(pcszErrorMessage) <= MAX_REA_PHRASE_LEN)) |
|
| 800 |
- {
|
|
| 801 |
-- strcpy(errorMessage, pErrorMessage); |
|
| 802 |
-+ strcpy(errorMessage, pcszErrorMessage); |
|
| 803 |
- } |
|
| 804 |
- |
|
| 805 |
- dwError = VmRESTSetHttpStatusCode( |
|
| 806 |
-diff --git a/transport/api/api.c b/transport/api/api.c |
|
| 807 |
-index c48de46..cc2c930 100644 |
|
| 808 |
-+++ b/transport/api/api.c |
|
| 809 |
-@@ -19,7 +19,7 @@ |
|
| 810 |
- #endif |
|
| 811 |
- |
|
| 812 |
- DWORD |
|
| 813 |
--VmwSockOpenServer( |
|
| 814 |
-+VmwSockStartServer( |
|
| 815 |
- PVMREST_HANDLE pRESTHandle, |
|
| 816 |
- VM_SOCK_CREATE_FLAGS dwFlags, |
|
| 817 |
- PVM_SOCKET* ppSocket |
|
| 818 |
-@@ -33,7 +33,7 @@ VmwSockOpenServer( |
|
| 819 |
- BAIL_ON_VMSOCK_ERROR(dwError); |
|
| 820 |
- } |
|
| 821 |
- |
|
| 822 |
-- dwError = pRESTHandle->pPackage->pfnOpenServerSocket( |
|
| 823 |
-+ dwError = pRESTHandle->pPackage->pfnStartServerSocket( |
|
| 824 |
- pRESTHandle, |
|
| 825 |
- dwFlags, |
|
| 826 |
- ppSocket); |
|
| 827 |
-@@ -64,7 +64,7 @@ VmwSockCreateEventQueue( |
|
| 828 |
- } |
|
| 829 |
- |
|
| 830 |
- DWORD |
|
| 831 |
--VmwSockEventQueueAdd( |
|
| 832 |
-+VmwSockAddEventToQueueInLock( |
|
| 833 |
- PVMREST_HANDLE pRESTHandle, |
|
| 834 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 835 |
- PVM_SOCKET pSocket |
|
| 836 |
-@@ -78,13 +78,36 @@ VmwSockEventQueueAdd( |
|
| 837 |
- BAIL_ON_VMSOCK_ERROR(dwError); |
|
| 838 |
- } |
|
| 839 |
- |
|
| 840 |
-- dwError = pRESTHandle->pPackage->pfnAddEventQueue(pRESTHandle,pQueue, pSocket); |
|
| 841 |
-+ dwError = pRESTHandle->pPackage->pfnAddEventToQueue(pRESTHandle,pQueue, pSocket); |
|
| 842 |
- |
|
| 843 |
- error: |
|
| 844 |
- |
|
| 845 |
- return dwError; |
|
| 846 |
- } |
|
| 847 |
- |
|
| 848 |
-+DWORD |
|
| 849 |
-+VmwSockDeleteEventFromQueue( |
|
| 850 |
-+ PVMREST_HANDLE pRESTHandle, |
|
| 851 |
-+ PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 852 |
-+ PVM_SOCKET pSocket |
|
| 853 |
-+ ) |
|
| 854 |
-+{
|
|
| 855 |
-+ DWORD dwError = REST_ENGINE_SUCCESS; |
|
| 856 |
-+ |
|
| 857 |
-+ if (!pQueue || !pSocket || !pRESTHandle) |
|
| 858 |
-+ {
|
|
| 859 |
-+ dwError = ERROR_INVALID_PARAMETER; |
|
| 860 |
-+ BAIL_ON_VMSOCK_ERROR(dwError); |
|
| 861 |
-+ } |
|
| 862 |
-+ |
|
| 863 |
-+ dwError = pRESTHandle->pPackage->pfnDeleteEventFromQueue(pRESTHandle,pQueue, pSocket); |
|
| 864 |
-+ |
|
| 865 |
-+error: |
|
| 866 |
-+ |
|
| 867 |
-+ return dwError; |
|
| 868 |
-+} |
|
| 869 |
-+ |
|
| 870 |
-+ |
|
| 871 |
- DWORD |
|
| 872 |
- VmwSockWaitForEvent( |
|
| 873 |
- PVMREST_HANDLE pRESTHandle, |
|
| 874 |
-diff --git a/transport/posix/libmain.c b/transport/posix/libmain.c |
|
| 875 |
-index e7a5056..67c6023 100644 |
|
| 876 |
-+++ b/transport/posix/libmain.c |
|
| 877 |
-@@ -47,9 +47,10 @@ VmRESTGetSockPackagePosix( |
|
| 878 |
- |
|
| 879 |
- pSockPackagePosix = *ppSockPackagePosix; |
|
| 880 |
- |
|
| 881 |
-- pSockPackagePosix->pfnOpenServerSocket = &VmSockPosixOpenServer; |
|
| 882 |
-+ pSockPackagePosix->pfnStartServerSocket = &VmSockPosixStartServer; |
|
| 883 |
- pSockPackagePosix->pfnCreateEventQueue = &VmSockPosixCreateEventQueue; |
|
| 884 |
-- pSockPackagePosix->pfnAddEventQueue = &VmSockPosixEventQueueAdd; |
|
| 885 |
-+ pSockPackagePosix->pfnAddEventToQueue = &VmSockPosixAddEventToQueueInLock; |
|
| 886 |
-+ pSockPackagePosix->pfnDeleteEventFromQueue = &VmSockPosixDeleteEventFromQueue; |
|
| 887 |
- pSockPackagePosix->pfnWaitForEvent = &VmSockPosixWaitForEvent; |
|
| 888 |
- pSockPackagePosix->pfnCloseEventQueue = &VmSockPosixCloseEventQueue; |
|
| 889 |
- pSockPackagePosix->pfnRead = &VmSockPosixRead; |
|
| 890 |
-diff --git a/transport/posix/prototypes.h b/transport/posix/prototypes.h |
|
| 891 |
-index 4fa664c..d60e5e2 100644 |
|
| 892 |
-+++ b/transport/posix/prototypes.h |
|
| 893 |
-@@ -12,7 +12,7 @@ |
|
| 894 |
- */ |
|
| 895 |
- |
|
| 896 |
- DWORD |
|
| 897 |
--VmSockPosixOpenServer( |
|
| 898 |
-+VmSockPosixStartServer( |
|
| 899 |
- PVMREST_HANDLE pRESTHandle, |
|
| 900 |
- VM_SOCK_CREATE_FLAGS dwFlags, |
|
| 901 |
- PVM_SOCKET* ppSocket |
|
| 902 |
-@@ -25,7 +25,14 @@ VmSockPosixCreateEventQueue( |
|
| 903 |
- ); |
|
| 904 |
- |
|
| 905 |
- DWORD |
|
| 906 |
--VmSockPosixEventQueueAdd( |
|
| 907 |
-+VmSockPosixAddEventToQueueInLock( |
|
| 908 |
-+ PVMREST_HANDLE pRESTHandle, |
|
| 909 |
-+ PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 910 |
-+ PVM_SOCKET pSocket |
|
| 911 |
-+ ); |
|
| 912 |
-+ |
|
| 913 |
-+DWORD |
|
| 914 |
-+VmSockPosixDeleteEventFromQueue( |
|
| 915 |
- PVMREST_HANDLE pRESTHandle, |
|
| 916 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 917 |
- PVM_SOCKET pSocket |
|
| 918 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
| 919 |
-index ec7ed3d..b34ef15 100644 |
|
| 920 |
-+++ b/transport/posix/socket.c |
|
| 921 |
-@@ -22,19 +22,12 @@ VmSockPosixCreateSignalSockets( |
|
| 922 |
- |
|
| 923 |
- static |
|
| 924 |
- DWORD |
|
| 925 |
--VmSockPosixEventQueueAdd_inlock( |
|
| 926 |
-+VmSockPosixAddEventToQueue( |
|
| 927 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 928 |
- BOOLEAN bOneShot, |
|
| 929 |
- PVM_SOCKET pSocket |
|
| 930 |
- ); |
|
| 931 |
- |
|
| 932 |
--static |
|
| 933 |
--DWORD |
|
| 934 |
--VmSockPosixEventQueueDelete_inlock( |
|
| 935 |
-- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 936 |
-- PVM_SOCKET pSocket |
|
| 937 |
-- ); |
|
| 938 |
-- |
|
| 939 |
- static |
|
| 940 |
- DWORD |
|
| 941 |
- VmSockPosixAcceptConnection( |
|
| 942 |
-@@ -99,7 +92,7 @@ VmRESTCreateSSLObject( |
|
| 943 |
- |
|
| 944 |
- |
|
| 945 |
- DWORD |
|
| 946 |
--VmSockPosixOpenServer( |
|
| 947 |
-+VmSockPosixStartServer( |
|
| 948 |
- PVMREST_HANDLE pRESTHandle, |
|
| 949 |
- VM_SOCK_CREATE_FLAGS dwFlags, |
|
| 950 |
- PVM_SOCKET* ppSocket |
|
| 951 |
-@@ -388,7 +381,7 @@ VmSockPosixCreateEventQueue( |
|
| 952 |
- pQueue->bShutdown = 0; |
|
| 953 |
- pQueue->thrCnt = pRESTHandle->pRESTConfig->nWorkerThr; |
|
| 954 |
- |
|
| 955 |
-- dwError = VmSockPosixEventQueueAdd_inlock( |
|
| 956 |
-+ dwError = VmSockPosixAddEventToQueue( |
|
| 957 |
- pQueue, |
|
| 958 |
- FALSE, |
|
| 959 |
- pQueue->pSignalReader |
|
| 960 |
-@@ -420,7 +413,7 @@ VmSockPosixCreateEventQueue( |
|
| 961 |
- } |
|
| 962 |
- |
|
| 963 |
- DWORD |
|
| 964 |
--VmSockPosixEventQueueAdd( |
|
| 965 |
-+VmSockPosixAddEventToQueueInLock( |
|
| 966 |
- PVMREST_HANDLE pRESTHandle, |
|
| 967 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 968 |
- PVM_SOCKET pSocket |
|
| 969 |
-@@ -441,7 +434,7 @@ VmSockPosixEventQueueAdd( |
|
| 970 |
- |
|
| 971 |
- bLocked = TRUE; |
|
| 972 |
- |
|
| 973 |
-- dwError = VmSockPosixEventQueueAdd_inlock( |
|
| 974 |
-+ dwError = VmSockPosixAddEventToQueue( |
|
| 975 |
- pQueue, |
|
| 976 |
- FALSE, |
|
| 977 |
- pSocket |
|
| 978 |
-@@ -462,6 +455,39 @@ VmSockPosixEventQueueAdd( |
|
| 979 |
- goto cleanup; |
|
| 980 |
- } |
|
| 981 |
- |
|
| 982 |
-+DWORD |
|
| 983 |
-+VmSockPosixDeleteEventFromQueue( |
|
| 984 |
-+ PVMREST_HANDLE pRESTHandle, |
|
| 985 |
-+ PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 986 |
-+ PVM_SOCKET pSocket |
|
| 987 |
-+ ) |
|
| 988 |
-+{
|
|
| 989 |
-+ DWORD dwError = REST_ENGINE_SUCCESS; |
|
| 990 |
-+ struct epoll_event event = {0};
|
|
| 991 |
-+ |
|
| 992 |
-+ if (!pSocket || !pQueue || !pRESTHandle) |
|
| 993 |
-+ {
|
|
| 994 |
-+ dwError = REST_ERROR_INVALID_HANDLER; |
|
| 995 |
-+ } |
|
| 996 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 997 |
-+ |
|
| 998 |
-+ if (epoll_ctl(pQueue->epollFd, EPOLL_CTL_DEL, pSocket->fd, &event) < 0) |
|
| 999 |
-+ {
|
|
| 1000 |
-+ dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 1001 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 1002 |
-+ } |
|
| 1003 |
-+ |
|
| 1004 |
-+cleanup: |
|
| 1005 |
-+ |
|
| 1006 |
-+ return dwError; |
|
| 1007 |
-+ |
|
| 1008 |
-+error: |
|
| 1009 |
-+ |
|
| 1010 |
-+ goto cleanup; |
|
| 1011 |
-+ |
|
| 1012 |
-+} |
|
| 1013 |
-+ |
|
| 1014 |
-+ |
|
| 1015 |
- DWORD |
|
| 1016 |
- VmSockPosixWaitForEvent( |
|
| 1017 |
- PVMREST_HANDLE pRESTHandle, |
|
| 1018 |
-@@ -539,7 +565,8 @@ VmSockPosixWaitForEvent( |
|
| 1019 |
- if (pEvent->events & (EPOLLERR | EPOLLHUP)) |
|
| 1020 |
- {
|
|
| 1021 |
- eventType = VM_SOCK_EVENT_TYPE_CONNECTION_CLOSED; |
|
| 1022 |
-- dwError = VmSockPosixEventQueueDelete_inlock( |
|
| 1023 |
-+ dwError = VmSockPosixDeleteEventFromQueue( |
|
| 1024 |
-+ pRESTHandle, |
|
| 1025 |
- pQueue, |
|
| 1026 |
- pEventSocket |
|
| 1027 |
- ); |
|
| 1028 |
-@@ -577,7 +604,7 @@ VmSockPosixWaitForEvent( |
|
| 1029 |
- } |
|
| 1030 |
- |
|
| 1031 |
- /**** Start watching new connection ****/ |
|
| 1032 |
-- dwError = VmSockPosixEventQueueAdd_inlock( |
|
| 1033 |
-+ dwError = VmSockPosixAddEventToQueue( |
|
| 1034 |
- pQueue, |
|
| 1035 |
- TRUE, |
|
| 1036 |
- pSocket |
|
| 1037 |
-@@ -639,6 +666,7 @@ VmSockPosixWaitForEvent( |
|
| 1038 |
- if (bFound) |
|
| 1039 |
- {
|
|
| 1040 |
- VMREST_LOG_DEBUG(pRESTHandle,"Action: DEFERRED, IO sock found in queue(Succeeding), Io Sock %d, timer %d", pSocket->pIoSocket->fd, pSocket->fd ); |
|
| 1041 |
-+ pEventSocket->pIoSocket->pTimerSocket = NULL; |
|
| 1042 |
- } |
|
| 1043 |
- else |
|
| 1044 |
- {
|
|
| 1045 |
-@@ -651,17 +679,30 @@ VmSockPosixWaitForEvent( |
|
| 1046 |
- {
|
|
| 1047 |
- /**** We are good to close actual IO Socket here ****/ |
|
| 1048 |
- VMREST_LOG_INFO(pRESTHandle,"Action: IO DELETION, IoSocket %d, timer %d", pSocket->pIoSocket->fd, pSocket->fd ); |
|
| 1049 |
-- eventType = VM_SOCK_EVENT_TYPE_CONNECTION_TIMEOUT; |
|
| 1050 |
-- pSocket = pSocket->pIoSocket; |
|
| 1051 |
-- |
|
| 1052 |
-+ |
|
| 1053 |
-+ pSocket = pEventSocket->pIoSocket; |
|
| 1054 |
- /**** Delete IO from queue ****/ |
|
| 1055 |
-- VmSockPosixEventQueueDelete_inlock( |
|
| 1056 |
-+ VmSockPosixDeleteEventFromQueue( |
|
| 1057 |
-+ pRESTHandle, |
|
| 1058 |
- pQueue, |
|
| 1059 |
- pSocket |
|
| 1060 |
- ); |
|
| 1061 |
-+ |
|
| 1062 |
-+ if ((pRESTHandle->pSSLInfo->isSecure) && (!(pSocket->bSSLHandShakeCompleted))) |
|
| 1063 |
-+ {
|
|
| 1064 |
-+ /**** SSL handshake is not completed, no response will be sent, free IoSocket ****/ |
|
| 1065 |
-+ pEventSocket->pIoSocket = NULL; |
|
| 1066 |
-+ VmSockPosixCloseSocket(pRESTHandle,pSocket); |
|
| 1067 |
-+ VmSockPosixReleaseSocket(pRESTHandle,pSocket); |
|
| 1068 |
-+ eventType = VM_SOCK_EVENT_TYPE_UNKNOWN; |
|
| 1069 |
-+ } |
|
| 1070 |
-+ else |
|
| 1071 |
-+ {
|
|
| 1072 |
-+ eventType = VM_SOCK_EVENT_TYPE_CONNECTION_TIMEOUT; |
|
| 1073 |
-+ pEventSocket->pIoSocket->pTimerSocket = NULL; |
|
| 1074 |
-+ } |
|
| 1075 |
- } |
|
| 1076 |
- } |
|
| 1077 |
-- pEventSocket->pIoSocket->pTimerSocket = NULL; |
|
| 1078 |
- } |
|
| 1079 |
- |
|
| 1080 |
- /** Close and free the timer socket ****/ |
|
| 1081 |
-@@ -747,7 +788,14 @@ VmSockPosixWaitForEvent( |
|
| 1082 |
- |
|
| 1083 |
- error: |
|
| 1084 |
- |
|
| 1085 |
-- VMREST_LOG_ERROR(pRESTHandle,"Error while processing socket event, dwError = %u", dwError); |
|
| 1086 |
-+ if ((dwError == ERROR_SHUTDOWN_IN_PROGRESS) && pQueue) |
|
| 1087 |
-+ {
|
|
| 1088 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Shutting down...Cleaning worker thread %d", (pQueue->thrCnt + 1)); |
|
| 1089 |
-+ } |
|
| 1090 |
-+ else |
|
| 1091 |
-+ {
|
|
| 1092 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Error while processing socket event, dwError = %u", dwError); |
|
| 1093 |
-+ } |
|
| 1094 |
- if (ppSocket) |
|
| 1095 |
- {
|
|
| 1096 |
- *ppSocket = NULL; |
|
| 1097 |
-@@ -987,10 +1035,11 @@ VmSockPosixRead( |
|
| 1098 |
- |
|
| 1099 |
- error: |
|
| 1100 |
- |
|
| 1101 |
-- if (pSocket && pRESTHandle->pSockContext) |
|
| 1102 |
-+ if (pSocket && pRESTHandle && pRESTHandle->pSockContext) |
|
| 1103 |
- {
|
|
| 1104 |
- /**** Delete the socket from poller ****/ |
|
| 1105 |
-- VmSockPosixEventQueueDelete_inlock( |
|
| 1106 |
-+ VmSockPosixDeleteEventFromQueue( |
|
| 1107 |
-+ pRESTHandle, |
|
| 1108 |
- pRESTHandle->pSockContext->pEventQueue, |
|
| 1109 |
- pSocket |
|
| 1110 |
- ); |
|
| 1111 |
-@@ -1001,15 +1050,12 @@ VmSockPosixRead( |
|
| 1112 |
- |
|
| 1113 |
- if (pSocket->pTimerSocket) |
|
| 1114 |
- {
|
|
| 1115 |
-+ pSocket->pTimerSocket->pIoSocket = NULL; |
|
| 1116 |
- VmSockPosixReArmTimer( |
|
| 1117 |
- pRESTHandle, |
|
| 1118 |
- pSocket->pTimerSocket, |
|
| 1119 |
-- ((pRESTHandle->pRESTConfig->connTimeoutSec) * 1000) |
|
| 1120 |
-+ 1 |
|
| 1121 |
- ); |
|
| 1122 |
-- |
|
| 1123 |
-- write(pSocket->pTimerSocket->fd, "NotifyPQ", 8); |
|
| 1124 |
-- pSocket->pTimerSocket->pIoSocket = NULL; |
|
| 1125 |
-- |
|
| 1126 |
- } |
|
| 1127 |
- |
|
| 1128 |
- } |
|
| 1129 |
-@@ -1191,7 +1237,7 @@ VmSockPosixCloseSocket( |
|
| 1130 |
- if (ret < 0) |
|
| 1131 |
- {
|
|
| 1132 |
- errorCode = SSL_get_error(pSocket->ssl, ret); |
|
| 1133 |
-- VMREST_LOG_ERROR(pRESTHandle,"Error on SSL_shutdown on socket %d, return value %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 1134 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Error on SSL_shutdown on socket %d, return value %d, errorCode %u, errno %d", pSocket->fd, ret, errorCode, errno); |
|
| 1135 |
- } |
|
| 1136 |
- SSL_free(pSocket->ssl); |
|
| 1137 |
- pSocket->ssl = NULL; |
|
| 1138 |
-@@ -1303,7 +1349,7 @@ VmSockPosixCreateSignalSockets( |
|
| 1139 |
- |
|
| 1140 |
- static |
|
| 1141 |
- DWORD |
|
| 1142 |
--VmSockPosixEventQueueAdd_inlock( |
|
| 1143 |
-+VmSockPosixAddEventToQueue( |
|
| 1144 |
- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 1145 |
- BOOLEAN bOneShot, |
|
| 1146 |
- PVM_SOCKET pSocket |
|
| 1147 |
-@@ -1337,33 +1383,6 @@ VmSockPosixEventQueueAdd_inlock( |
|
| 1148 |
- return dwError; |
|
| 1149 |
- } |
|
| 1150 |
- |
|
| 1151 |
--static |
|
| 1152 |
--DWORD |
|
| 1153 |
--VmSockPosixEventQueueDelete_inlock( |
|
| 1154 |
-- PVM_SOCK_EVENT_QUEUE pQueue, |
|
| 1155 |
-- PVM_SOCKET pSocket |
|
| 1156 |
-- ) |
|
| 1157 |
--{
|
|
| 1158 |
-- DWORD dwError = REST_ENGINE_SUCCESS; |
|
| 1159 |
-- struct epoll_event event = {0};
|
|
| 1160 |
-- |
|
| 1161 |
-- if (!pSocket || !pQueue) |
|
| 1162 |
-- {
|
|
| 1163 |
-- dwError = REST_ERROR_INVALID_HANDLER; |
|
| 1164 |
-- } |
|
| 1165 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1166 |
-- |
|
| 1167 |
-- if (epoll_ctl(pQueue->epollFd, EPOLL_CTL_DEL, pSocket->fd, &event) < 0) |
|
| 1168 |
-- {
|
|
| 1169 |
-- dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 1170 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1171 |
-- } |
|
| 1172 |
-- |
|
| 1173 |
--error: |
|
| 1174 |
-- |
|
| 1175 |
-- return dwError; |
|
| 1176 |
--} |
|
| 1177 |
-- |
|
| 1178 |
- static |
|
| 1179 |
- DWORD |
|
| 1180 |
- VmSockPosixAcceptConnection( |
|
| 1181 |
-@@ -1637,7 +1656,8 @@ VmSockPosixSetRequestHandle( |
|
| 1182 |
- } |
|
| 1183 |
- |
|
| 1184 |
- /**** Delete actual IO socket from poller ****/ |
|
| 1185 |
-- dwError = VmSockPosixEventQueueDelete_inlock( |
|
| 1186 |
-+ dwError = VmSockPosixDeleteEventFromQueue( |
|
| 1187 |
-+ pRESTHandle, |
|
| 1188 |
- pQueue, |
|
| 1189 |
- pSocket |
|
| 1190 |
- ); |
|
| 1191 |
-@@ -1868,7 +1888,7 @@ VmSockPosixCreateTimer( |
|
| 1192 |
- ); |
|
| 1193 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1194 |
- |
|
| 1195 |
-- dwError = VmSockPosixEventQueueAdd_inlock( |
|
| 1196 |
-+ dwError = VmSockPosixAddEventToQueue( |
|
| 1197 |
- pRESTHandle->pSockContext->pEventQueue, |
|
| 1198 |
- TRUE, |
|
| 1199 |
- pTimerSocket |
|
| 1200 |
-@@ -1923,50 +1943,44 @@ VmRESTAcceptSSLContext( |
|
| 1201 |
- |
|
| 1202 |
- if (ret == 1) |
|
| 1203 |
- {
|
|
| 1204 |
-- VMREST_LOG_DEBUG(pRESTHandle," SSL accept successful on socket %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 1205 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"SSL accept successful on socket %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 1206 |
- pSocket->bSSLHandShakeCompleted = TRUE; |
|
| 1207 |
- bReArm = TRUE; |
|
| 1208 |
- } |
|
| 1209 |
- else if ((ret == -1) && ((errorCode == SSL_ERROR_WANT_READ) || (errorCode == SSL_ERROR_WANT_WRITE))) |
|
| 1210 |
- {
|
|
| 1211 |
-- VMREST_LOG_DEBUG(pRESTHandle," SSL handshake not completed for socket %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 1212 |
-+ VMREST_LOG_DEBUG(pRESTHandle,"SSL handshake not completed for socket %d, ret %d, errorCode %u", pSocket->fd, ret, errorCode); |
|
| 1213 |
- pSocket->bSSLHandShakeCompleted = FALSE; |
|
| 1214 |
- bReArm = TRUE; |
|
| 1215 |
- } |
|
| 1216 |
-- else if ((ret == 0) && (errorCode == SSL_ERROR_SYSCALL)) |
|
| 1217 |
-+ else |
|
| 1218 |
- {
|
|
| 1219 |
-- VMREST_LOG_ERROR(pRESTHandle," Client closed the connection during SSL handshake, socket fd %d, ret %d, errorCode %u, errno %d", pSocket->fd, ret, errorCode, errno); |
|
| 1220 |
-+ VMREST_LOG_ERROR(pRESTHandle,"SSL handshake failed on socket fd %d, ret %d, errorCode %u, errno %d", pSocket->fd, ret, errorCode, errno); |
|
| 1221 |
- dwError = VMREST_TRANSPORT_SSL_ACCEPT_FAILED; |
|
| 1222 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1223 |
- } |
|
| 1224 |
-- else |
|
| 1225 |
-+ |
|
| 1226 |
-+ if (bReArm && bWatched) |
|
| 1227 |
- {
|
|
| 1228 |
-- VMREST_LOG_ERROR(pRESTHandle, "SSL handshake failed...connection will be closed for socket with fd %d, ret %d, errorCode %u, errno %d", pSocket->fd, ret, errorCode, errno); |
|
| 1229 |
-- dwError = VMREST_TRANSPORT_SSL_ACCEPT_FAILED; |
|
| 1230 |
-+ /**** Rearm and add the socket ****/ |
|
| 1231 |
-+ dwError = VmSockPosixReArmTimer( |
|
| 1232 |
-+ pRESTHandle, |
|
| 1233 |
-+ pSocket->pTimerSocket, |
|
| 1234 |
-+ ((pRESTHandle->pRESTConfig->connTimeoutSec) * 1000) |
|
| 1235 |
-+ ); |
|
| 1236 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1237 |
-- } |
|
| 1238 |
- |
|
| 1239 |
-- if (bReArm && bWatched) |
|
| 1240 |
-- {
|
|
| 1241 |
-- /**** Rearm and add the socket ****/ |
|
| 1242 |
-- dwError = VmSockPosixReArmTimer( |
|
| 1243 |
-- pRESTHandle, |
|
| 1244 |
-- pSocket->pTimerSocket, |
|
| 1245 |
-- ((pRESTHandle->pRESTConfig->connTimeoutSec) * 1000) |
|
| 1246 |
-- ); |
|
| 1247 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1248 |
-- |
|
| 1249 |
-- event.data.ptr = pSocket; |
|
| 1250 |
-- event.events = EPOLLIN; |
|
| 1251 |
-+ event.data.ptr = pSocket; |
|
| 1252 |
-+ event.events = EPOLLIN; |
|
| 1253 |
- |
|
| 1254 |
-- event.events = event.events | EPOLLONESHOT; |
|
| 1255 |
-+ event.events = event.events | EPOLLONESHOT; |
|
| 1256 |
- |
|
| 1257 |
-- if (epoll_ctl(pRESTHandle->pSockContext->pEventQueue->epollFd, EPOLL_CTL_MOD, pSocket->fd, &event) < 0) |
|
| 1258 |
-- {
|
|
| 1259 |
-- dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 1260 |
-- BAIL_ON_VMREST_ERROR(dwError); |
|
| 1261 |
-- } |
|
| 1262 |
-- } |
|
| 1263 |
-+ if (epoll_ctl(pRESTHandle->pSockContext->pEventQueue->epollFd, EPOLL_CTL_MOD, pSocket->fd, &event) < 0) |
|
| 1264 |
-+ {
|
|
| 1265 |
-+ dwError = VM_SOCK_POSIX_ERROR_SYS_CALL_FAILED; |
|
| 1266 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 1267 |
-+ } |
|
| 1268 |
-+ } |
|
| 1269 |
- |
|
| 1270 |
- cleanup: |
|
| 1271 |
- |
|
| 1272 |
-@@ -1977,7 +1991,8 @@ VmRESTAcceptSSLContext( |
|
| 1273 |
- if (pRESTHandle && pRESTHandle->pSockContext) |
|
| 1274 |
- {
|
|
| 1275 |
- /**** Delete from poller ****/ |
|
| 1276 |
-- VmSockPosixEventQueueDelete_inlock( |
|
| 1277 |
-+ VmSockPosixDeleteEventFromQueue( |
|
| 1278 |
-+ pRESTHandle, |
|
| 1279 |
- pRESTHandle->pSockContext->pEventQueue, |
|
| 1280 |
- pSocket |
|
| 1281 |
- ); |
| 1282 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,180 +0,0 @@ |
| 1 |
-From 3fbf376fe21d544bfe1373c17369fd8f916813da Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
| 3 |
-Date: Fri, 15 Dec 2017 18:36:44 -0800 |
|
| 4 |
-Subject: [PATCH] Adding minimal INFO level packet trace logging |
|
| 5 |
- |
|
| 6 |
-Change-Id: I932706c8446b44c70aa8a015852e28a65f0b4a16 |
|
| 7 |
-(cherry picked from commit 305dda1d5e242dd78f3e867232e6f0247b8fdf10) |
|
| 8 |
- server/restengine/httpProtocolHead.c | 19 ++++++++++++++++--- |
|
| 9 |
- server/restengine/httpUtilsExternal.c | 4 ++-- |
|
| 10 |
- server/restengine/restProtocolHead.c | 2 +- |
|
| 11 |
- transport/posix/socket.c | 6 ++++++ |
|
| 12 |
- 4 files changed, 25 insertions(+), 6 deletions(-) |
|
| 13 |
- |
|
| 14 |
-diff --git a/server/restengine/httpProtocolHead.c b/server/restengine/httpProtocolHead.c |
|
| 15 |
-index 0a1e5e5..18cff08 100644 |
|
| 16 |
-+++ b/server/restengine/httpProtocolHead.c |
|
| 17 |
-@@ -598,6 +598,7 @@ VmRESTSendHeader( |
|
| 18 |
- ); |
|
| 19 |
- buffer = NULL; |
|
| 20 |
- } |
|
| 21 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Sending header data failed"); |
|
| 22 |
- goto cleanup; |
|
| 23 |
- } |
|
| 24 |
- |
|
| 25 |
-@@ -669,6 +670,7 @@ VmRESTSendChunkedPayload( |
|
| 26 |
- ); |
|
| 27 |
- buffer = NULL; |
|
| 28 |
- } |
|
| 29 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Sending chunked payload data failed"); |
|
| 30 |
- goto cleanup; |
|
| 31 |
- } |
|
| 32 |
- |
|
| 33 |
-@@ -777,6 +779,7 @@ VmRESTSendHeaderAndPayload( |
|
| 34 |
- ); |
|
| 35 |
- buffer = NULL; |
|
| 36 |
- } |
|
| 37 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Sending header and payload data failed"); |
|
| 38 |
- goto cleanup; |
|
| 39 |
- } |
|
| 40 |
- |
|
| 41 |
-@@ -1209,6 +1212,7 @@ VmRESTProcessHeaders( |
|
| 42 |
- {
|
|
| 43 |
- *nProcessed = 0; |
|
| 44 |
- } |
|
| 45 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Failed while processing headers... dwError %u", dwError); |
|
| 46 |
- goto cleanup; |
|
| 47 |
- |
|
| 48 |
- } |
|
| 49 |
-@@ -1313,13 +1317,15 @@ VmRESTProcessPayload( |
|
| 50 |
- return dwError; |
|
| 51 |
- |
|
| 52 |
- error: |
|
| 53 |
-- VMREST_LOG_ERROR(pRESTHandle,"Errorcode %u", dwError); |
|
| 54 |
-- |
|
| 55 |
- if (dwError == REST_ENGINE_MORE_IO_REQUIRED) |
|
| 56 |
- {
|
|
| 57 |
- *nProcessed = 0; |
|
| 58 |
- dwError = REST_ENGINE_SUCCESS; |
|
| 59 |
- } |
|
| 60 |
-+ else |
|
| 61 |
-+ {
|
|
| 62 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Failed while processing payload ... dwError %u", dwError); |
|
| 63 |
-+ } |
|
| 64 |
- goto cleanup; |
|
| 65 |
- |
|
| 66 |
- } |
|
| 67 |
-@@ -1396,12 +1402,17 @@ VmRESTProcessBuffer( |
|
| 68 |
- |
|
| 69 |
- case PROCESS_APPLICATION_CALLBACK: |
|
| 70 |
- /**** Give callback to application ****/ |
|
| 71 |
-- VMREST_LOG_DEBUG(pRESTHandle,"%s","Giving callback to application..."); |
|
| 72 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s","C-REST-ENGINE: Giving callback to application..."); |
|
| 73 |
- dwError = VmRESTTriggerAppCb( |
|
| 74 |
- pRESTHandle, |
|
| 75 |
- pRequest, |
|
| 76 |
- &(pRequest->pResponse) |
|
| 77 |
- ); |
|
| 78 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Application callback returns dwError %u", dwError); |
|
| 79 |
-+ if ((dwError != REST_ENGINE_SUCCESS) && pRequest && pRequest->pResponse && pRequest->pResponse->statusLine) |
|
| 80 |
-+ {
|
|
| 81 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Status code: %s, header sent %d", pRequest->pResponse->statusLine->statusCode, pRequest->pResponse->bHeaderSent); |
|
| 82 |
-+ } |
|
| 83 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 84 |
- bInitiateClose = TRUE; |
|
| 85 |
- break; |
|
| 86 |
-@@ -1428,6 +1439,7 @@ VmRESTProcessBuffer( |
|
| 87 |
- |
|
| 88 |
- error: |
|
| 89 |
- |
|
| 90 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Process buffer failed with error code %u, sending failure response", dwError); |
|
| 91 |
- ret = VmRESTSendFailureResponse( |
|
| 92 |
- pRESTHandle, |
|
| 93 |
- dwError, |
|
| 94 |
-@@ -1475,6 +1487,7 @@ VmRESTTriggerAppCb( |
|
| 95 |
- dwError = VMREST_APPLICATION_VALIDATION_FAILED; |
|
| 96 |
- } |
|
| 97 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 98 |
-+ |
|
| 99 |
- |
|
| 100 |
- pRequest->state = PROCESS_INVALID; |
|
| 101 |
- |
|
| 102 |
-diff --git a/server/restengine/httpUtilsExternal.c b/server/restengine/httpUtilsExternal.c |
|
| 103 |
-index b75756d..a9e9222 100644 |
|
| 104 |
-+++ b/server/restengine/httpUtilsExternal.c |
|
| 105 |
-@@ -258,7 +258,7 @@ VmRESTGetHttpPayload( |
|
| 106 |
- |
|
| 107 |
- return dwError; |
|
| 108 |
- error: |
|
| 109 |
-- |
|
| 110 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Get payload failed with error code %u", dwError); |
|
| 111 |
- goto cleanup; |
|
| 112 |
- |
|
| 113 |
- } |
|
| 114 |
-@@ -375,7 +375,7 @@ VmRESTSetHttpPayload( |
|
| 115 |
- cleanup: |
|
| 116 |
- return dwError; |
|
| 117 |
- error: |
|
| 118 |
-- VMREST_LOG_ERROR(pRESTHandle,"%s","Set Payload Failed"); |
|
| 119 |
-+ VMREST_LOG_ERROR(pRESTHandle,"Set Payload Failed with error Code %u", dwError); |
|
| 120 |
- goto cleanup; |
|
| 121 |
- } |
|
| 122 |
- |
|
| 123 |
-diff --git a/server/restengine/restProtocolHead.c b/server/restengine/restProtocolHead.c |
|
| 124 |
-index 0446d1a..53a5864 100644 |
|
| 125 |
-+++ b/server/restengine/restProtocolHead.c |
|
| 126 |
-@@ -76,7 +76,7 @@ VmRestEngineHandler( |
|
| 127 |
- ptr = NULL; |
|
| 128 |
- } |
|
| 129 |
- |
|
| 130 |
-- VMREST_LOG_DEBUG(pRESTHandle,"HTTP URI %s", httpURI); |
|
| 131 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: HTTP URI %s", httpURI); |
|
| 132 |
- |
|
| 133 |
- /**** 4. Get the End point from URI ****/ |
|
| 134 |
- dwError = VmRestGetEndPointURIfromRequestURI( |
|
| 135 |
-diff --git a/transport/posix/socket.c b/transport/posix/socket.c |
|
| 136 |
-index 18cef89..6c0e14e 100644 |
|
| 137 |
-+++ b/transport/posix/socket.c |
|
| 138 |
-@@ -553,10 +553,12 @@ VmSockPosixWaitForEvent( |
|
| 139 |
- } |
|
| 140 |
- else if (pEventSocket->type == VM_SOCK_TYPE_LISTENER) |
|
| 141 |
- {
|
|
| 142 |
-+ VMREST_LOG_INFO(pRESTHandle,"%s","C-REST-ENGINE: ======================== NEW REQUEST =========================="); |
|
| 143 |
- dwError = VmSockPosixAcceptConnection( |
|
| 144 |
- pEventSocket, |
|
| 145 |
- &pSocket); |
|
| 146 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 147 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Accepted new connection with socket fd %d", pSocket->fd); |
|
| 148 |
- |
|
| 149 |
- dwError = VmSockPosixSetNonBlocking(pRESTHandle,pSocket); |
|
| 150 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 151 |
-@@ -694,6 +696,7 @@ VmSockPosixWaitForEvent( |
|
| 152 |
- |
|
| 153 |
- error: |
|
| 154 |
- |
|
| 155 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s","Socket layer - wait for event error"); |
|
| 156 |
- if (ppSocket) |
|
| 157 |
- {
|
|
| 158 |
- *ppSocket = NULL; |
|
| 159 |
-@@ -1077,6 +1080,7 @@ VmSockPosixWrite( |
|
| 160 |
- |
|
| 161 |
- error: |
|
| 162 |
- |
|
| 163 |
-+ VMREST_LOG_ERROR(pRESTHandle,"%s", "Socket write failed"); |
|
| 164 |
- goto cleanup; |
|
| 165 |
- } |
|
| 166 |
- |
|
| 167 |
-@@ -1114,6 +1118,8 @@ VmSockPosixCloseSocket( |
|
| 168 |
- } |
|
| 169 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 170 |
- |
|
| 171 |
-+ VMREST_LOG_INFO(pRESTHandle,"C-REST-ENGINE: Closing socket with fd %d", pSocket->fd); |
|
| 172 |
-+ |
|
| 173 |
- dwError = VmRESTLockMutex(pSocket->pMutex); |
|
| 174 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 175 |
- |
| 176 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,57 +0,0 @@ |
| 1 |
-From 36f7b88cfedf404ff8ef02ed2e2092ca963cb384 Mon Sep 17 00:00:00 2001 |
|
| 2 |
-From: Kumar Kaushik <kaushikk@vmware.com> |
|
| 3 |
-Date: Tue, 30 Jan 2018 18:30:46 -0800 |
|
| 4 |
-Subject: [PATCH] Improper request line parsing check |
|
| 5 |
- |
|
| 6 |
-Change-Id: I606bfd18efe8fe9cd4d9cf7533e4991e81c74ae2 |
|
| 7 |
- server/restengine/httpProtocolHead.c | 14 ++++++++++---- |
|
| 8 |
- 1 file changed, 10 insertions(+), 4 deletions(-) |
|
| 9 |
- |
|
| 10 |
-diff --git a/server/restengine/httpProtocolHead.c b/server/restengine/httpProtocolHead.c |
|
| 11 |
-index 95089a3..a7ca54a 100644 |
|
| 12 |
-+++ b/server/restengine/httpProtocolHead.c |
|
| 13 |
-@@ -1001,7 +1001,7 @@ VmRESTProcessRequestLine( |
|
| 14 |
- {
|
|
| 15 |
- /**** 1. Parsing HTTP METHOD ****/ |
|
| 16 |
- pszFirstSpace = strchr(pszStartNewLine, ' '); |
|
| 17 |
-- if (pszFirstSpace != NULL && ((pszFirstSpace - pszStartNewLine) <= MAX_METHOD_LEN)) |
|
| 18 |
-+ if (pszFirstSpace != NULL && ((pszFirstSpace - pszStartNewLine) <= MAX_METHOD_LEN) && ((pszFirstSpace - pszStartNewLine) > 0)) |
|
| 19 |
- {
|
|
| 20 |
- strncpy(pRequest->requestLine->method, pszStartNewLine, (pszFirstSpace - pszStartNewLine)); |
|
| 21 |
- pRequest->requestLine->method[pszFirstSpace - pszStartNewLine] = '\0'; |
|
| 22 |
-@@ -1016,13 +1016,13 @@ VmRESTProcessRequestLine( |
|
| 23 |
- /**** 2. Parse HTTP URI****/ |
|
| 24 |
- pszSecondSpace = strchr((pszFirstSpace + 1), ' '); |
|
| 25 |
- |
|
| 26 |
-- if (pszSecondSpace != NULL && ((pszSecondSpace - pszFirstSpace) < MAX_URI_LEN)) |
|
| 27 |
-+ if (pszSecondSpace != NULL && ((pszSecondSpace - pszFirstSpace) < MAX_URI_LEN) && ((pszSecondSpace - pszFirstSpace) > 0)) |
|
| 28 |
- {
|
|
| 29 |
- strncpy(pRequest->requestLine->uri, (pszFirstSpace + 1), (pszSecondSpace - pszFirstSpace - 1)); |
|
| 30 |
- pRequest->requestLine->uri[pszSecondSpace - pszFirstSpace - 1] = '\0'; |
|
| 31 |
- |
|
| 32 |
- /**** 3. Parse HTTP Version ****/ |
|
| 33 |
-- if ((pszEndNewLine - pszSecondSpace - 1) <= HTTP_VER_LEN) |
|
| 34 |
-+ if (((pszEndNewLine - pszSecondSpace - 1) <= HTTP_VER_LEN) && ((pszEndNewLine - pszSecondSpace - 1) > 0)) |
|
| 35 |
- {
|
|
| 36 |
- strncpy(pRequest->requestLine->version, (pszSecondSpace + 1), (pszEndNewLine - pszSecondSpace - 1)); |
|
| 37 |
- pRequest->requestLine->version[pszEndNewLine - pszSecondSpace - 1] = '\0'; |
|
| 38 |
-@@ -1198,10 +1198,16 @@ VmRESTProcessHeaders( |
|
| 39 |
- BAIL_ON_VMREST_ERROR(dwError); |
|
| 40 |
- } |
|
| 41 |
- } |
|
| 42 |
-- else /**** pszEndNewLine = NULL ****/ |
|
| 43 |
-+ else if (nBytes < MAX_REQ_LIN_LEN) /**** pszEndNewLine = NULL ****/ |
|
| 44 |
- {
|
|
| 45 |
- VMREST_LOG_DEBUG(pRESTHandle,"Incomplete line processing.. wait for IO.., bytesProcessed %u, nBytes %u", bytesProcessed, nBytes); |
|
| 46 |
- } |
|
| 47 |
-+ else |
|
| 48 |
-+ {
|
|
| 49 |
-+ dwError = BAD_REQUEST; |
|
| 50 |
-+ BAIL_ON_VMREST_ERROR(dwError); |
|
| 51 |
-+ } |
|
| 52 |
-+ |
|
| 53 |
- |
|
| 54 |
- cleanup: |
|
| 55 |
- |
| 56 | 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 |
- } |