/* Forward referenced functions */
void terminate_stored(int sig);
static void check_config();
-static void *director_thread(void *arg);
#define CONFIG_FILE "bacula-sd.conf" /* Default config file */
/* This is our own global resource */
-static STORES *me;
+STORES *me;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static uint32_t VolSessionId = 0;
static int foreground = 0;
static workq_t dird_workq; /* queue for processing connections */
-static workq_t filed_workq; /* queue for processing connections */
static void usage()
int no_signals = FALSE;
int test_config = FALSE;
DEVRES *device;
- pthread_t dirid;
- int status;
init_stack_dump();
my_name_is(argc, argv, "stored");
device->dev->max_file_size = device->max_file_size;
device->dev->volume_capacity = device->volume_capacity;
device->dev->max_rewind_wait = device->max_rewind_wait;
+ device->dev->max_open_wait = device->max_open_wait;
device->dev->device = device;
}
- Dmsg1(10, "Init done %s\n", device->device_name);
+ Dmsg1(10, "SD init done %s\n", device->device_name);
if (!device->dev) {
Emsg1(M_ERROR, 0, _("Could not initialize %s\n"), device->device_name);
}
UnlockRes();
device = NULL;
- start_watchdog(); /* start watchdog thread */
+ set_thread_concurrency(me->max_concurrent_jobs * 2 +
+ 4 /* watch dog + servers + misc */);
- /*
- * Here we support either listening on one port or on two ports
- */
- if (me->SDDport == 0 || me->SDDport == me->SDport) {
- /* Single server used for Director and File daemon */
- bnet_thread_server(me->SDport, 20, &dird_workq, connection_request);
- } else {
- /* Start the Director server */
- set_thread_concurrency(10);
- if ((status=pthread_create(&dirid, NULL, director_thread,
- (void *)me->SDport)) != 0) {
- Emsg1(M_ABORT, 0, _("Cannot create Director thread: %s\n"), strerror(status));
- }
- /* Start File daemon server */
- bnet_thread_server(me->SDDport, 10, &filed_workq, connection_from_filed);
- /* never returns */
- }
+ start_watchdog(); /* start watchdog thread */
+ /* Single server used for Director and File daemon */
+ bnet_thread_server(me->SDaddr, me->SDport, me->max_concurrent_jobs * 2 + 1,
+ &dird_workq, connection_request);
exit(1); /* to keep compiler quiet */
}
-static void *director_thread(void *arg)
-{
- int dir_port = (int)arg;
- pthread_detach(pthread_self());
- bnet_thread_server(dir_port, 10, &dird_workq, connection_request);
- return NULL;
-}
-
/* Return a new Session Id */
uint32_t newVolSessionId()
{