MSW: fixed some other close->closesocket occurencies

This commit is contained in:
Martin Pulec
2015-03-13 16:29:35 +01:00
parent 3a77ccb398
commit 68bf4383ae
2 changed files with 22 additions and 8 deletions

View File

@@ -71,6 +71,11 @@ typedef const char *sso_val_type;
typedef void *sso_val_type;
#endif /* WIN32 */
#ifdef WIN32
#define CLOSESOCKET closesocket
#else
#define CLOSESOCKET close
#endif
using namespace std;
@@ -264,7 +269,7 @@ void control_start(struct control_state *s)
}
s->internal_fd[0] = accept(sock, NULL, NULL);
close(sock);
CLOSESOCKET(sock);
s->started = true;
}
@@ -588,7 +593,7 @@ static void * control_thread(void *args)
}
if(ret == 0) {
struct client *next;
close(cur->fd);
CLOSESOCKET(cur->fd);
if(cur->prev) {
cur->prev->next = cur->next;
} else {
@@ -673,12 +678,12 @@ static void * control_thread(void *args)
struct client *cur = clients;
while(cur) {
struct client *tmp = cur;
close(cur->fd);
CLOSESOCKET(cur->fd);
cur = cur->next;
free(tmp);
}
close(s->internal_fd[1]);
CLOSESOCKET(s->internal_fd[1]);
return NULL;
}
@@ -695,7 +700,7 @@ void control_done(struct control_state *s)
int ret = write_all(s->internal_fd[0], "quit\r\n", 6);
if (ret > 0) {
pthread_join(s->thread_id, NULL);
close(s->internal_fd[0]);
CLOSESOCKET(s->internal_fd[0]);
} else {
fprintf(stderr, "Cannot exit control thread!\n");
}
@@ -703,7 +708,7 @@ void control_done(struct control_state *s)
if(s->connection_type == SERVER) {
// for client, the socket has already been closed
// by the time of control_thread exit
close(s->socket_fd);
CLOSESOCKET(s->socket_fd);
}
pthread_mutex_destroy(&s->stats_lock);

View File

@@ -13,6 +13,13 @@
#include <stdio.h>
#include "debug.h"
#ifdef WIN32
#define CLOSESOCKET closesocket
#else
#define CLOSESOCKET close
#endif
void usage(const char *progname);
int main(int argc, char *argv[]);
void sig_handler(int signal);
@@ -25,7 +32,7 @@ int fd = -1;// = socket(AF_INET6, SOCK_STREAM, 0);
void sig_handler(int signal) {
UNUSED(signal);
close(fd);
CLOSESOCKET(fd);
endwin();
exit(EXIT_SUCCESS);
}
@@ -165,7 +172,9 @@ finish:
#endif
pthread_join(reading_thread_id, NULL);
close(fd);
#ifndef WIN32
CLOSESOCKET(fd);
#endif
endwin();
#ifdef WIN32