Merge pull request #58 from Nitrokey/fix_simulation

Avoid 2nd start of the simulation server
This commit is contained in:
Conor Patrick 2019-01-23 19:02:30 -05:00 committed by GitHub
commit c556fcd8c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,7 +54,11 @@ void device_set_status(int status)
int udp_server() int udp_server()
{ {
int fd; static bool run_already = false;
static int fd = -1;
if (run_already && fd >= 0) return fd;
run_already = true;
if ( (fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) { if ( (fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
perror( "socket failed" ); perror( "socket failed" );
return 1; return 1;