Skip to content

Commit be8daad

Browse files
committed
AXL_Init and AXL_Finalize CI testing works
1 parent e9082d7 commit be8daad

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

src/axl_socket.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static kvtree* service_request_AXL_Config_Set(int sd)
127127
}
128128
#endif
129129

130-
static ssize_t service_request_from_client(int sd)
130+
static ssize_t axl_socket_request_from_client(int sd)
131131
{
132132
ssize_t bytecount;
133133
axl_socket_Request req;
@@ -171,6 +171,7 @@ static ssize_t service_request_from_client(int sd)
171171

172172
static void sigterm_handler(int sig, siginfo_t* info, void* ucontext)
173173
{
174+
AXL_DBG(2, "SIGTERM Received");
174175
time_to_leave++;
175176
}
176177

@@ -250,12 +251,15 @@ int axl_socket_server_run(int port)
250251

251252
activity = select(max_sd + 1 , &readfds , NULL , NULL , NULL);
252253

254+
if (time_to_leave)
255+
break;
256+
253257
if (activity < 0 && errno != EINTR) {
254258
AXL_ABORT(-1, "select() error: (%s)", strerror(errno));
255259
}
256260

257261
if (FD_ISSET(server_socket, &readfds)) {
258-
AXL_DBG(0, "Accepting new incomming connection");
262+
AXL_DBG(1, "Accepting new incomming connection");
259263
if ((new_socket = accept(server_socket, (struct sockaddr *)&address,
260264
(socklen_t*)&addrlen)) < 0) {
261265
AXL_ABORT(-1, "accept() error: (%s)", strerror(errno));
@@ -267,15 +271,15 @@ int axl_socket_server_run(int port)
267271
break;
268272
}
269273
}
270-
AXL_DBG(0, "Connection established");
274+
AXL_DBG(1, "Connection established");
271275
}
272276

273277
for ( int i = 0; i < AXL_SOCKET_MAX_CLIENTS; i++) {
274278
if (FD_ISSET(axl_socket_conn_ctx_array[i].sd , &readfds)) {
275279
axl_xfer_list = &axl_socket_conn_ctx_array[i].xfr;
276280

277-
if (service_request_from_client(axl_socket_conn_ctx_array[i].sd) == 0) {
278-
AXL_DBG(0, "Closing server side socket(%d) to client", axl_socket_conn_ctx_array[i].sd);
281+
if (axl_socket_request_from_client(axl_socket_conn_ctx_array[i].sd) == 0) {
282+
AXL_DBG(1, "Closing server side socket(%d) to client", axl_socket_conn_ctx_array[i].sd);
279283
close(axl_socket_conn_ctx_array[i].sd);
280284
axl_socket_conn_ctx_array[i].sd = 0;
281285
axl_free(&axl_xfer_list->axl_kvtrees);

test/test_client_server.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ int run_service()
2525

2626
int run_client()
2727
{
28-
fprintf(stdout, "Client Started!\n");
29-
sleep(2);
30-
fprintf(stdout, "Client Ending!\n");
31-
return AXLCS_SUCCESS;
28+
int rval;
29+
30+
if ((rval = AXL_Init()) != AXL_SUCCESS) {
31+
fprintf(stderr, "Call to AXL_Init failed with code: %d\n", rval);
32+
} else {
33+
if ((rval = AXL_Finalize()) != AXL_SUCCESS) {
34+
fprintf(stderr, "Call to AXL_Init failed with code: %d\n", rval);
35+
}
36+
}
37+
38+
return rval;
3239
}
3340

3441
int main(int ac, char **av)

test/test_driver_client_server.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import subprocess
55
import os
6+
import time
67

78
def wait_for_completion(procname, proc, wait_time):
89
try:
@@ -20,8 +21,11 @@ def wait_for_completion(procname, proc, wait_time):
2021
if __name__ == '__main__':
2122
errors = 0
2223
# Launch the server then the client
23-
server = subprocess.Popen(['./test_client_server', '--server'], env=dict(os.environ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
24-
client = subprocess.Popen(['./test_client_server', '--client'], env=dict(os.environ), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
24+
test_env = {'AXL_DEBUG': '44', 'AXL_SERVICE_HOST': 'localhost', 'AXL_SERVICE_PORT': '2000'}
25+
server = subprocess.Popen(['./test_client_server', '--server'], env=dict(os.environ, **test_env), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
26+
time.sleep(2) # Give server a chance to start
27+
28+
client = subprocess.Popen(['./test_client_server', '--client'], env=dict(os.environ, **test_env), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
2529

2630
# Wait for the client then the server to finish
2731
client_ecode, client_out, client_err = wait_for_completion("axl_client", client, 30)

0 commit comments

Comments
 (0)