Lines Matching defs:adhost

104 descriptors_cleanup(struct adist_host *adhost)
110 if (adh == adhost)
126 child_cleanup(struct adist_host *adhost)
129 if (adhost->adh_conn != NULL) {
130 PJDLOG_ASSERT(adhost->adh_role == ADIST_ROLE_SENDER);
131 proto_close(adhost->adh_conn);
132 adhost->adh_conn = NULL;
134 adhost->adh_worker_pid = 0;
156 struct adist_host *adhost;
164 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
165 if (pid == adhost->adh_worker_pid)
168 if (adhost == NULL) {
171 if (adhost->adh_role == ADIST_ROLE_SENDER)
173 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
174 role2str(adhost->adh_role));
176 child_cleanup(adhost);
184 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
185 if (adhost->adh_role != ADIST_ROLE_SENDER)
187 if (adhost->adh_worker_pid != 0)
189 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
190 role2str(adhost->adh_role));
192 adist_sender(adcfg, adhost);
208 struct adist_host *adhost;
211 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
212 if (adhost->adh_worker_pid == 0)
214 pjdlog_info("Terminating worker process (adhost=%s, role=%s, pid=%u).",
215 adhost->adh_name, role2str(adhost->adh_role),
216 adhost->adh_worker_pid);
217 if (kill(adhost->adh_worker_pid, SIGTERM) == 0)
220 "Unable to send signal to worker process (adhost=%s, role=%s, pid=%u).",
221 adhost->adh_name, role2str(adhost->adh_role),
222 adhost->adh_worker_pid);
230 struct adist_host *adhost;
258 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
259 if (adhost->adh_role != ADIST_ROLE_RECEIVER)
261 if (!proto_address_match(conn, adhost->adh_remoteaddr))
265 if (adhost == NULL) {
276 adhost->adh_remoteaddr);
282 adhost->adh_remoteaddr);
292 adhost->adh_remoteaddr);
296 if (proto_recv(conn, adname, sizeof(adhost->adh_name)) < 0) {
303 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
304 if (adhost->adh_role != ADIST_ROLE_RECEIVER)
306 if (!proto_address_match(conn, adhost->adh_remoteaddr))
308 if (strcmp(adhost->adh_name, adname) != 0)
312 if (adhost == NULL) {
318 adhost->adh_version = version;
319 pjdlog_debug(1, "Version %d negotiated with %s.", adhost->adh_version,
320 adhost->adh_remoteaddr);
323 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
324 role2str(adhost->adh_role));
334 adhost->adh_remoteaddr);
341 adhost->adh_remoteaddr);
346 if (HMAC(EVP_sha256(), adhost->adh_password,
347 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
356 adhost->adh_remoteaddr);
363 adhost->adh_remoteaddr);
368 if (HMAC(EVP_sha256(), adhost->adh_password,
369 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
378 adhost->adh_remoteaddr);
383 if (adhost->adh_worker_pid != 0) {
386 (unsigned int)adhost->adh_worker_pid);
388 if (kill(adhost->adh_worker_pid, SIGINT) == -1) {
391 (unsigned int)adhost->adh_worker_pid);
398 else if ((pid = waitpid(adhost->adh_worker_pid,
399 &status, 0)) != adhost->adh_worker_pid) {
403 (unsigned int)adhost->adh_worker_pid);
405 child_exit_log("Worker", adhost->adh_worker_pid,
408 child_cleanup(adhost);
411 adhost->adh_remote = conn;
412 adist_receiver(adcfg, adhost);
422 connection_migrate(struct adist_host *adhost)
427 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
428 role2str(adhost->adh_role));
430 PJDLOG_ASSERT(adhost->adh_role == ADIST_ROLE_SENDER);
432 if (proto_recv(adhost->adh_conn, &val, sizeof(val)) < 0) {
437 if (proto_set("tls:fingerprint", adhost->adh_fingerprint) == -1) {
442 if (proto_connect(adhost->adh_localaddr[0] != '\0' ?
443 adhost->adh_localaddr : NULL,
444 adhost->adh_remoteaddr, -1, &conn) < 0) {
447 adhost->adh_remoteaddr);
452 if (proto_send(adhost->adh_conn, &val, sizeof(val)) < 0) {
456 if (val == 0 && proto_connection_send(adhost->adh_conn, conn) < 0)
501 struct adist_host *adhost;
526 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
527 if (adhost->adh_role == ADIST_ROLE_SENDER) {
529 PJDLOG_ASSERT(adhost->adh_conn != NULL);
530 fd = proto_descriptor(adhost->adh_conn);
535 PJDLOG_ASSERT(adhost->adh_conn == NULL);
567 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
568 if (adhost->adh_role == ADIST_ROLE_SENDER) {
569 PJDLOG_ASSERT(adhost->adh_conn != NULL);
570 if (FD_ISSET(proto_descriptor(adhost->adh_conn),
572 connection_migrate(adhost);
575 PJDLOG_ASSERT(adhost->adh_conn == NULL);
584 struct adist_host *adhost;
601 TAILQ_FOREACH(adhost, &cfg->adc_hosts, adh_next) {
602 pjdlog_debug(2, " name: %s", adhost->adh_name);
603 pjdlog_debug(2, " role: %s", role2str(adhost->adh_role));
604 pjdlog_debug(2, " version: %d", adhost->adh_version);
605 pjdlog_debug(2, " localaddr: %s", adhost->adh_localaddr);
606 pjdlog_debug(2, " remoteaddr: %s", adhost->adh_remoteaddr);
607 pjdlog_debug(2, " remote: %p", adhost->adh_remote);
608 pjdlog_debug(2, " directory: %s", adhost->adh_directory);
609 pjdlog_debug(2, " compression: %d", adhost->adh_compression);
610 pjdlog_debug(2, " checksum: %d", adhost->adh_checksum);
611 pjdlog_debug(2, " pid: %ld", (long)adhost->adh_worker_pid);
612 pjdlog_debug(2, " conn: %p", adhost->adh_conn);
625 struct adist_host *adhost;
792 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
793 if (adhost->adh_role == ADIST_ROLE_SENDER)
794 adist_sender(adcfg, adhost);