Skip to content

Commit

Permalink
[httpd] avoid compilation error on older libmicrohttpd versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ionutrazvanionita committed Feb 27, 2017
1 parent 0052453 commit e2010b5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/httpd/httpd_proc.c
Expand Up @@ -411,9 +411,11 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection,
int cnt_type = HTTPD_STD_CNT_TYPE;
int accept_type = HTTPD_STD_CNT_TYPE;
int ret_code = MHD_HTTP_OK;
int sv_sockfd;

#if ( MHD_VERSION >= 0x000092800 )
int sv_sockfd;
socklen_t addrlen=sizeof(httpd_server_info);
#endif
union sockaddr_union* cl_socket;

LM_DBG("START *** cls=%p, connection=%p, url=%s, method=%s, "
Expand All @@ -438,8 +440,8 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection,
cl_socket = (union sockaddr_union *)MHD_get_connection_info(connection,
MHD_CONNECTION_INFO_CLIENT_ADDRESS)->client_addr;

#if ( MHD_VERSION >= 0x000092800 )
sv_sockfd = MHD_get_connection_info(connection, MHD_CONNECTION_INFO_CONNECTION_FD)->connect_fd;

getsockname( sv_sockfd, &httpd_server_info.s, &addrlen);

/* we could do
Expand All @@ -448,6 +450,7 @@ int answer_to_connection (void *cls, struct MHD_Connection *connection,
* httpd server
*/
httpd_server_info.sin.sin_port = port;
#endif

if(strncmp(method, "POST", 4)==0) {
if(pr == NULL){
Expand Down Expand Up @@ -734,6 +737,13 @@ void httpd_proc(int rank)
saddr_in.sin_family = AF_INET;
saddr_in.sin_port = htons(port);


#if ( MHD_VERSION < 0x000092800 )
memcpy( &httpd_server_info, &saddr_in, sizeof(struct sockaddr_in) );
httpd_server_info.sin_port = port;
#endif


LM_DBG("init_child [%d] - [%d] HTTP Server init [%s:%d]\n",
rank, getpid(), (ip.s?ip.s:"INADDR_ANY"), port);
set_proc_attrs("HTTPD %s:%d", (ip.s?ip.s:"INADDR_ANY"), port);
Expand Down

0 comments on commit e2010b5

Please sign in to comment.