Beispiel #1
0
int control_init()
{
  int r;
  r = control_readline(&me,"etc/me");
  if (r == 1) meok = 1;
  return r;
}
Beispiel #2
0
int control_rldef(stralloc *sa,char *fn,int flagme,char *def)
{
  int r;
  r = control_readline(sa,fn);
  if (r) return r;
  if (flagme) if (meok) return stralloc_copy(sa,&me) ? 1 : -1;
  if (def) return stralloc_copys(sa,def) ? 1 : -1;
  return r;
}
Beispiel #3
0
int control_readint(int *i,char *fn)
{
  unsigned long u;
  switch(control_readline(&line,fn))
  {
    case 0: return 0;
    case -1: return -1;
  }
  if (!stralloc_0(&line)) return -1;
  if (!scan_ulong(line.s,&u)) return 0;
  *i = u;
  return 1;
}
Beispiel #4
0
void *cliserver(void *arg) {

        struct srv_ctx *srv = (struct srv_ctx *)arg;
        struct freeq_ctx *freeqctx = srv->freeqctx;
        struct conn_ctx *conn_ctx;
        int res;
        pthread_t tid;
        BIO *acc, *client;

        static stralloc aggport = {0};

        res = control_readline(&aggport, "control/aggport");
        if (!res)
        {
                err(freeqctx, "unable to read control/aggport");
                exit(FREEQ_ERR);
        }

        stralloc_0(&aggport);

        dbg(freeqctx, "starting aggregation listener on %s\n", (char *)aggport.s);
        acc = BIO_new_accept((char *)aggport.s);
        if (!acc)
        {
                int_error("Error creating server socket");
                exit(FREEQ_ERR);
        }

        if (BIO_do_accept(acc) <= 0)
                int_error("Error binding server socket");

        for (;;)
        {
                dbg(freeqctx, "waiting for connection\n");
                if (BIO_do_accept(acc) <= 0)
                        int_error("Error accepting connection");
                dbg(freeqctx, "accepted connection, setting up ssl\n");

                //bio_peername(acc);

                client = BIO_pop(acc);
                conn_ctx = malloc(sizeof(struct conn_ctx));
                conn_ctx->srvctx = srv;
                conn_ctx->client = client;
                pthread_create(&tid, 0, &conn_handler, (void *)conn_ctx);
        }
}
Beispiel #5
0
void *sqlserver(void *arg) {
        struct srv_ctx *srv = (struct srv_ctx *)arg;
        struct freeq_ctx *freeqctx = srv->freeqctx;
        int res;
        pthread_t thread;
        BIO *acc, *client;

        signal(SIGINT, cleanup);
        signal(SIGTERM, cleanup);
        signal(SIGPIPE, SIG_IGN);

        static stralloc sqlport = {0};

        res = control_readline(&sqlport, "control/sqlport");
        if (!res)
        {
                err(freeqctx, "unable to read control/sqlport\n");
                exit(FREEQ_ERR);
        }

        stralloc_0(&sqlport);
        dbg(freeqctx, "starting query listener on %s\n", (char *)sqlport.s);
        acc = BIO_new_accept((char *)sqlport.s);
        if (!acc)
        {
                int_error("Error creating server socket");
                exit(FREEQ_ERR);
        }

        if (BIO_do_accept(acc) <= 0)
                int_error("Error binding server socket");

        for (;;)
        {
                if (BIO_do_accept(acc) <= 0)
                        int_error("Error accepting connection");
                client = BIO_pop(acc);
                struct conn_ctx *conn = malloc(sizeof(struct conn_ctx));
                conn->srvctx = srv;
                conn->client = client;
                pthread_create(&thread, 0, &sqlhandler, (void *)conn);
        }

        BIO_free(acc);
        pthread_exit(FREEQ_OK);;
}