aboutsummaryrefslogtreecommitdiff
path: root/server.c
Commit message (Collapse)AuthorAgeFilesLines
* server.c: Fix typoXavier Del Campo Romero2023-07-061-1/+1
|
* server.c: Fix undefined behaviour on >1 clientsXavier Del Campo Romero2023-07-031-45/+45
| | | | | | | | | | | | | | server.c kept an array of all of its active clients, calling realloc(3) everytime its size had to be modified. However, reallocating this array had the undesired consequence of moving other active clients to other memory locations. Potentially, this would result in dangling pointers from other components that also kept pointers to struct server_client instances e.g.: handler.c. For this reason, the array-based approach has been completely dropped, in favour of a doubly-linked list.
* Avoid crashing on SIGPIPEXavier Del Campo Romero2023-05-011-2/+18
| | | | | | | | | Under some circumstances, clients could cause SIGPIPE to slcl. Since this signal was not handled by server.c (i.e., via sigaction(3)), slcl would crash without any error messages printed to stderr. In such situation, SIGPIPE should not be usually considered a fatal error, so it is preferrable to close the connection and keep working.
* Replace select(2) with poll(2)Xavier Del Campo Romero2023-05-011-26/+65
| | | | | | select(2) has a number of well-known issues (e.g.: FD_SETSIZE limiting the maximum amount of file descriptors to watch) that are mostly solved by poll(2) and thus can be used as a drop-in replacement.
* Define _POSIX_C_SOURCEXavier Del Campo Romero2023-03-241-0/+2
| | | | | This allows using the default compiler defined by make(1) (i.e., c99(1)), thus improving POSIX compatibility.
* server.c: Fix wrong size for memcpy(3)Xavier Del Campo Romero2023-03-081-4/+5
|
* server.c: Minor const-correctness improvementXavier Del Campo Romero2023-03-071-1/+1
|
* Fix memory leak on failed realloc(3)Xavier Del Campo Romero2023-03-041-6/+18
| | | | | | | | | | According to C99 ยง7.20.3.4: If memory for the new object cannot be allocated, the old object is not deallocated and its value is unchanged. Therefore, a temporary pointer must be used to ensure the original object can still be deallocated should realloc(3) return a null pointer.
* Initial commitXavier Del Campo Romero2023-02-281-0/+303