corrections mémoire
This commit is contained in:
parent
af3c9395ff
commit
b8c367d6c4
@ -16,7 +16,7 @@ $(EXEC): $(OBJECTS) $(CFILES)
|
|||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
$(TESTS):
|
$(TESTS):
|
||||||
valgrind --show-leak-kinds=all --leak-check=full -v --track-origins=yes ./$(basename $@)
|
valgrind --show-leak-kinds=all --leak-check=full -v --track-origins=yes ./$(basename $@).bin
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@-rm $(OBJECTS)
|
@-rm $(OBJECTS)
|
||||||
|
@ -13,11 +13,10 @@
|
|||||||
|
|
||||||
int main (int argc, char * argv[])
|
int main (int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
argc = argc;
|
argc = argc;
|
||||||
argv = argv;
|
argv = argv;
|
||||||
|
|
||||||
int fd;
|
int fd = 0;
|
||||||
size_t msize = BUFSIZ;
|
size_t msize = BUFSIZ;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
@ -55,5 +54,8 @@ int main (int argc, char * argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf != NULL)
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -12,12 +12,11 @@
|
|||||||
|
|
||||||
int main (int argc, char * argv[])
|
int main (int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
argc = argc;
|
argc = argc;
|
||||||
argv = argv;
|
argv = argv;
|
||||||
|
|
||||||
int fd;
|
int fd = 0;
|
||||||
int pfd;
|
int pfd = 0;
|
||||||
size_t msize = BUFSIZ;
|
size_t msize = BUFSIZ;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
@ -63,5 +62,8 @@ int main (int argc, char * argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf != NULL)
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -53,5 +53,8 @@ int main (int argc, char *argv[], char *env[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf != NULL)
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ int main (int argc, char *argv[], char *env[])
|
|||||||
srv.version = 0;
|
srv.version = 0;
|
||||||
|
|
||||||
struct process p;
|
struct process p;
|
||||||
|
memset (&p, 0, sizeof (struct process));
|
||||||
|
|
||||||
// init service
|
// init service
|
||||||
if (srv_init (argc, argv, env, &srv, SERVICE_NAME) < 0) {
|
if (srv_init (argc, argv, env, &srv, SERVICE_NAME) < 0) {
|
||||||
@ -64,5 +65,8 @@ int main (int argc, char *argv[], char *env[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf != NULL)
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ int main (int argc, char * argv[])
|
|||||||
argc = argc;
|
argc = argc;
|
||||||
argv = argv;
|
argv = argv;
|
||||||
|
|
||||||
int fd;
|
int fd = 0;
|
||||||
size_t msize = BUFSIZ;
|
size_t msize = BUFSIZ;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
@ -48,5 +48,8 @@ int main (int argc, char * argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf != NULL)
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ int main (int argc, char * argv[])
|
|||||||
argc = argc;
|
argc = argc;
|
||||||
argv = argv;
|
argv = argv;
|
||||||
|
|
||||||
int fd;
|
int fd = 0;
|
||||||
int pfd;
|
int pfd = 0;
|
||||||
size_t msize = BUFSIZ;
|
size_t msize = BUFSIZ;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
@ -67,5 +67,8 @@ int main (int argc, char * argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf != NULL)
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ int srv_init (int argc, char **argv, char **env
|
|||||||
int srv_accept (struct service *srv, struct process *p)
|
int srv_accept (struct service *srv, struct process *p)
|
||||||
{
|
{
|
||||||
usock_accept (srv->service_fd, &p->proc_fd);
|
usock_accept (srv->service_fd, &p->proc_fd);
|
||||||
char *buf;
|
char *buf = NULL;
|
||||||
size_t msgsize = BUFSIZ;
|
size_t msgsize = BUFSIZ;
|
||||||
|
|
||||||
srv_read (p, &buf, &msgsize);
|
srv_read (p, &buf, &msgsize);
|
||||||
@ -57,6 +57,8 @@ int srv_accept (struct service *srv, struct process *p)
|
|||||||
|
|
||||||
srv_write (p, buf, msgsize);
|
srv_write (p, buf, msgsize);
|
||||||
|
|
||||||
|
free (buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,13 +106,14 @@ int app_connection (int argc, char **argv, char **env
|
|||||||
// TODO: connection algorithm
|
// TODO: connection algorithm
|
||||||
// send connection string and receive acknowledgement
|
// send connection string and receive acknowledgement
|
||||||
char send_buffer [BUFSIZ];
|
char send_buffer [BUFSIZ];
|
||||||
|
memset (send_buffer, 0, BUFSIZ);
|
||||||
if (msg_format_con (send_buffer, connectionstr, &msize) < 0) {
|
if (msg_format_con (send_buffer, connectionstr, &msize) < 0) {
|
||||||
handle_err ("app_connection", "msg_format_con");
|
handle_err ("app_connection", "msg_format_con");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
app_write (srv, send_buffer, msize);
|
app_write (srv, send_buffer, msize);
|
||||||
|
|
||||||
char *buffer;
|
char *buffer = NULL;
|
||||||
size_t read_msg_size = BUFSIZ;
|
size_t read_msg_size = BUFSIZ;
|
||||||
|
|
||||||
app_read (srv, &buffer, &read_msg_size);
|
app_read (srv, &buffer, &read_msg_size);
|
||||||
@ -118,6 +121,8 @@ int app_connection (int argc, char **argv, char **env
|
|||||||
assert (buffer[0] == MSG_TYPE_ACK);
|
assert (buffer[0] == MSG_TYPE_ACK);
|
||||||
assert (read_msg_size == 3);
|
assert (read_msg_size == 3);
|
||||||
|
|
||||||
|
free (buffer);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ int usock_accept (int fd, int *pfd)
|
|||||||
|
|
||||||
struct sockaddr_un peer_addr;
|
struct sockaddr_un peer_addr;
|
||||||
memset (&peer_addr, 0, sizeof (struct sockaddr_un));
|
memset (&peer_addr, 0, sizeof (struct sockaddr_un));
|
||||||
socklen_t peer_addr_size;
|
socklen_t peer_addr_size = 0;
|
||||||
|
|
||||||
*pfd = accept (fd, (struct sockaddr *) &peer_addr, &peer_addr_size);
|
*pfd = accept (fd, (struct sockaddr *) &peer_addr, &peer_addr_size);
|
||||||
if (*pfd < 0) {
|
if (*pfd < 0) {
|
||||||
|
Reference in New Issue
Block a user