*/
/*
- Copyright (C) 2000-2003 Kern Sibbald and John Walker
+ Copyright (C) 2000-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
/* Forward referenced functions */
-static void *connect_thread(void *arg);
+extern "C" void *connect_thread(void *arg);
+
static void *handle_UA_client_request(void *arg);
struct s_addr_port {
char *addr;
- int port;
+ char *port;
};
/* Called here by Director daemon to start UA (user agent)
* command thread. This routine creates the thread and then
* returns.
*/
-void start_UA_server(char *UA_addr, int UA_port)
+void start_UA_server(dlist *addrs)
{
pthread_t thid;
int status;
- static struct s_addr_port arg;
+ static dlist *myaddrs = addrs;
- arg.port = UA_port;
- arg.addr = UA_addr;
- if ((status=pthread_create(&thid, NULL, connect_thread, (void *)&arg)) != 0) {
- Emsg1(M_ABORT, 0, _("Cannot create UA thread: %s\n"), strerror(status));
+ if ((status=pthread_create(&thid, NULL, connect_thread, (void *)myaddrs)) != 0) {
+ berrno be;
+ be.set_errno(status);
+ Emsg1(M_ABORT, 0, _("Cannot create UA thread: %s\n"), be.strerror());
}
started = TRUE;
return;
}
-static void *connect_thread(void *arg)
+extern "C"
+void *connect_thread(void *arg)
{
- struct s_addr_port *UA = (struct s_addr_port *)arg;
-
pthread_detach(pthread_self());
- /* ****FIXME**** put # 5 on config parameter */
- bnet_thread_server(UA->addr, UA->port, 5, &ua_workq, handle_UA_client_request);
+ /* ****FIXME**** put # 10 (timeout) on config parameter */
+ bnet_thread_server((dlist*)arg, 10, &ua_workq, handle_UA_client_request);
return NULL;
}
* Create a Job Control Record for a control "job",
* filling in all the appropriate fields.
*/
-JCR *create_control_jcr(char *base_name, int job_type)
+JCR *new_control_jcr(const char *base_name, int job_type)
{
JCR *jcr;
jcr = new_jcr(sizeof(JCR), dird_free_jcr);
create_unique_job_name(jcr, base_name);
jcr->sched_time = jcr->start_time;
jcr->JobType = job_type;
- jcr->JobLevel = L_FULL;
+ jcr->JobLevel = L_NONE;
jcr->JobStatus = JS_Running;
- /* None of these are really defined for control JCRs, so we
+ jcr->JobId = 0;
+ /*
+ * None of these are really defined for control JCRs, so we
* simply take the first of each one. This ensures that there
* will be no null pointer references.
*/
pthread_detach(pthread_self());
- jcr = create_control_jcr("*Console*", JT_CONSOLE);
+ jcr = new_control_jcr("*Console*", JT_CONSOLE);
ua = new_ua_context(jcr);
ua->UA_sock = UA_sock;
while (!ua->quit) {
stat = bnet_recv(ua->UA_sock);
if (stat >= 0) {
- pm_strcpy(&ua->cmd, ua->UA_sock->msg);
+ pm_strcpy(ua->cmd, ua->UA_sock->msg);
parse_ua_args(ua);
if (ua->argc > 0 && ua->argk[0][0] == '.') {
do_a_dot_command(ua, ua->cmd);