Renamed function, removed now unnecessary thread data and prototyping.
This commit is contained in:
parent
fb74c24ec1
commit
ac43e37399
@ -54,25 +54,15 @@
|
|||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
typedef struct client_thread_data {
|
void guacd_handle_connection(int fd) {
|
||||||
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
} client_thread_data;
|
|
||||||
|
|
||||||
|
|
||||||
void* start_client_thread(void* data) {
|
|
||||||
|
|
||||||
guac_client* client;
|
guac_client* client;
|
||||||
guac_client_plugin* plugin;
|
guac_client_plugin* plugin;
|
||||||
guac_instruction* select;
|
guac_instruction* select;
|
||||||
guac_instruction* connect;
|
guac_instruction* connect;
|
||||||
|
|
||||||
/* Get thread data */
|
|
||||||
client_thread_data* thread_data = (client_thread_data*) data;
|
|
||||||
|
|
||||||
/* Open guac_socket */
|
/* Open guac_socket */
|
||||||
guac_socket* socket = guac_socket_open(thread_data->fd);
|
guac_socket* socket = guac_socket_open(fd);
|
||||||
|
|
||||||
/* Get protocol from select instruction */
|
/* Get protocol from select instruction */
|
||||||
select = guac_protocol_expect_instruction(
|
select = guac_protocol_expect_instruction(
|
||||||
@ -84,8 +74,7 @@ void* start_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Free resources */
|
/* Free resources */
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate args to select */
|
/* Validate args to select */
|
||||||
@ -97,8 +86,7 @@ void* start_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Free resources */
|
/* Free resources */
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog(LOG_INFO, "Protocol \"%s\" selected", select->argv[0]);
|
syslog(LOG_INFO, "Protocol \"%s\" selected", select->argv[0]);
|
||||||
@ -114,8 +102,7 @@ void* start_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Free resources */
|
/* Free resources */
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send args response */
|
/* Send args response */
|
||||||
@ -129,8 +116,7 @@ void* start_client_thread(void* data) {
|
|||||||
guacd_log_guac_error("Error closing client plugin");
|
guacd_log_guac_error("Error closing client plugin");
|
||||||
|
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get args from connect instruction */
|
/* Get args from connect instruction */
|
||||||
@ -145,8 +131,7 @@ void* start_client_thread(void* data) {
|
|||||||
guacd_log_guac_error("Error closing client plugin");
|
guacd_log_guac_error("Error closing client plugin");
|
||||||
|
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load and init client */
|
/* Load and init client */
|
||||||
@ -162,8 +147,7 @@ void* start_client_thread(void* data) {
|
|||||||
guacd_log_guac_error("Error closing client plugin");
|
guacd_log_guac_error("Error closing client plugin");
|
||||||
|
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up logging in client */
|
/* Set up logging in client */
|
||||||
@ -184,10 +168,8 @@ void* start_client_thread(void* data) {
|
|||||||
|
|
||||||
/* Close socket */
|
/* Close socket */
|
||||||
guac_socket_close(socket);
|
guac_socket_close(socket);
|
||||||
close(thread_data->fd);
|
|
||||||
|
|
||||||
free(data);
|
return;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +288,6 @@ int main(int argc, char* argv[]) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
client_thread_data* data;
|
|
||||||
|
|
||||||
/* Listen for connections */
|
/* Listen for connections */
|
||||||
if (listen(socket_fd, 5) < 0) {
|
if (listen(socket_fd, 5) < 0) {
|
||||||
@ -322,9 +303,6 @@ int main(int argc, char* argv[]) {
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = malloc(sizeof(client_thread_data));
|
|
||||||
data->fd = connected_socket_fd;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once connection is accepted, send child into background.
|
* Once connection is accepted, send child into background.
|
||||||
*
|
*
|
||||||
@ -342,7 +320,8 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
/* If child, start client, and exit when finished */
|
/* If child, start client, and exit when finished */
|
||||||
else if (child_pid == 0) {
|
else if (child_pid == 0) {
|
||||||
start_client_thread(data);
|
guacd_handle_connection(connected_socket_fd);
|
||||||
|
close(connected_socket_fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user