Przeglądaj źródła

Removed code dealing with child processes; btpd doesn't use them anymore.

master
Richard Nyberg 19 lat temu
rodzic
commit
6f09434ea0
2 zmienionych plików z 0 dodań i 44 usunięć
  1. +0
    -42
      btpd/btpd.c
  2. +0
    -2
      btpd/btpd.h

+ 0
- 42
btpd/btpd.c Wyświetl plik

@@ -29,20 +29,9 @@
#include "btpd.h"
#include "http.h"

struct child {
pid_t pid;
void *arg;
void (*cb)(pid_t, void *);
BTPDQ_ENTRY(child) entry;
};

BTPDQ_HEAD(child_tq, child);

static uint8_t m_peer_id[20];
static struct event m_sigint;
static struct event m_sigterm;
static struct event m_sigchld;
static struct child_tq m_kids = BTPDQ_HEAD_INITIALIZER(m_kids);
static unsigned m_ntorrents;
static struct torrent_tq m_torrents = BTPDQ_HEAD_INITIALIZER(m_torrents);

@@ -68,35 +57,6 @@ signal_cb(int signal, short type, void *arg)
btpd_shutdown();
}

void
btpd_add_child(pid_t pid, void (*cb)(pid_t, void *), void *arg)
{
struct child *kid = btpd_calloc(1, sizeof(*kid));
kid->pid = pid;
kid->arg = arg;
kid->cb = cb;
BTPDQ_INSERT_TAIL(&m_kids, kid, entry);
}

static void
child_cb(int signal, short type, void *arg)
{
int status;
pid_t pid;

while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
if (WIFEXITED(status) || WIFSIGNALED(status)) {
struct child *kid = BTPDQ_FIRST(&m_kids);
while (kid != NULL && kid->pid != pid)
kid = BTPDQ_NEXT(kid, entry);
assert(kid != NULL);
BTPDQ_REMOVE(&m_kids, kid, entry);
kid->cb(kid->pid, kid->arg);
free(kid);
}
}
}

void
btpd_add_torrent(struct torrent *tp)
{
@@ -271,6 +231,4 @@ btpd_init(void)
signal_add(&m_sigint, NULL);
signal_set(&m_sigterm, SIGTERM, signal_cb, NULL);
signal_add(&m_sigterm, NULL);
signal_set(&m_sigchld, SIGCHLD, child_cb, NULL);
signal_add(&m_sigchld, NULL);
}

+ 0
- 2
btpd/btpd.h Wyświetl plik

@@ -50,8 +50,6 @@ void *btpd_calloc(size_t nmemb, size_t size);

void btpd_shutdown(void);

void btpd_add_child(pid_t pid, void (*cb)(pid_t, void *), void *arg);

struct torrent * btpd_get_torrent(const uint8_t *hash);
const struct torrent_tq *btpd_get_torrents(void);
void btpd_add_torrent(struct torrent *tp);


Ładowanie…
Anuluj
Zapisz