Move some initialization closer to the client.
This commit is contained in:
5
adsbus.c
5
adsbus.c
@@ -1,9 +1,7 @@
|
|||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "backend.h"
|
#include "backend.h"
|
||||||
@@ -126,11 +124,10 @@ static bool parse_opts(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
signal(SIGPIPE, SIG_IGN);
|
|
||||||
|
|
||||||
server_init();
|
server_init();
|
||||||
peer_init();
|
peer_init();
|
||||||
hex_init();
|
hex_init();
|
||||||
|
client_init();
|
||||||
airspy_adsb_init();
|
airspy_adsb_init();
|
||||||
beast_init();
|
beast_init();
|
||||||
json_init();
|
json_init();
|
||||||
|
|||||||
5
client.c
5
client.c
@@ -5,6 +5,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
@@ -38,6 +39,10 @@ struct serializer {
|
|||||||
#define NUM_SERIALIZERS (sizeof(serializers) / sizeof(*serializers))
|
#define NUM_SERIALIZERS (sizeof(serializers) / sizeof(*serializers))
|
||||||
|
|
||||||
|
|
||||||
|
void client_init() {
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
}
|
||||||
|
|
||||||
static void client_hangup(struct client *client) {
|
static void client_hangup(struct client *client) {
|
||||||
fprintf(stderr, "C %s (%s): Client disconnected\n", client->id, client->serializer->name);
|
fprintf(stderr, "C %s (%s): Client disconnected\n", client->id, client->serializer->name);
|
||||||
if (client->prev) {
|
if (client->prev) {
|
||||||
|
|||||||
1
client.h
1
client.h
@@ -3,6 +3,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|
||||||
|
void client_init();
|
||||||
struct serializer *client_get_serializer(char *);
|
struct serializer *client_get_serializer(char *);
|
||||||
void client_add(int, struct serializer *);
|
void client_add(int, struct serializer *);
|
||||||
void client_add_wrapper(int, void *);
|
void client_add_wrapper(int, void *);
|
||||||
|
|||||||
Reference in New Issue
Block a user