-
Notifications
You must be signed in to change notification settings - Fork 0
Add listening server #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Work in progress ...)
Now compile on debian
src/launch_server.c
Outdated
| continue ; | ||
| } | ||
| inet_ntop(rem_addr.ss_family, get_in_addr((struct sockaddr *)&rem_addr), | ||
| str, sizeof str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(str)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evidemment, my bad.
| hints.ai_socktype = SOCK_STREAM; /* Use TCP stream socket */ | ||
|
|
||
| /* Get port number as a string */ | ||
| snprintf(port_str, 6, "%d", flags_get_port()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: snprintf met un \0 à la fin de la string ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man snprintf sous debian : The functions snprintf() and vsnprintf() write at most size bytes (including the terminating null byte ('\0')) to str.
Sous OSX : The snprintf() and vsnprintf() functions will write at most size-1 of the characters printed into the output string (the size'th character then gets the terminating \0'); if the return value is greater than or equal to the size argument, the string was too short and some of the printed characters were discarded. The output is always null-terminated, unless size is 0.`
src/launch_server.c
Outdated
| int sockfd = 0, /* Read on this one */ | ||
| rem_fd = 0, /* Fd that will be attributed to the client */ | ||
| rval; /* To stock getaddrinfo() return */ | ||
| s8_t enable = 1; /* Int to enable the option in setsockopt */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi signed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fondamentalement, pour rien, ca doit etre zero ou non-zero, tu préfère unsigned ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Booléen du coup, pour la clareté !
src/launch_server.c
Outdated
| #define BACKLOG 10 /* How many pending connection we will keep in queue */ | ||
|
|
||
| // get sockaddr, IPv4 or IPv6: | ||
| void *get_in_addr(struct sockaddr *sa) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vérifie que le pointeur qu'on t'envoie est pas NULL avant de déréférencer. Et si la fonction est utilisée nulle part ailleurs, met la static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
src/launch_server.c
Outdated
|
|
||
| char str[INET6_ADDRSTRLEN]; | ||
|
|
||
| memset(&hints, 0, sizeof hints); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof(hints)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je sais pas ce qui m'as pris sur les sizeof.
src/launch_server.c
Outdated
| sizeof(int)) == 1) | ||
| { | ||
| /* If it fails, display the error and exit */ | ||
| m_panic("Server: socket %s" , strerror(errno)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manque un freeaddrinfo ça leak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oublié effectivement, je patch.
- Forgot parenthesis after sizeof - Forgot a freeaddrinfo - Changed s8_t to u8_t - Checked for NULL parameters in get_in_addr - Made get_in_addr a static function
src/args.c
Outdated
|
|
||
| /** | ||
| * Path of the specifiedd PID file, if defined | ||
| * Path of the specifiedd PID file, if defined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifiedd
|
Ok pour le code, j'attend le fix du build + coverage pour merge |
Codecov Report
@@ Coverage Diff @@
## master #3 +/- ##
=====================================
- Coverage 100% 0% -100%
=====================================
Files 1 1
Lines 41 35 -6
=====================================
- Hits 41 0 -41
- Misses 0 35 +35
Continue to review full report at Codecov.
|
Server is listening and doing nothing.