Lines Matching refs:adhost

102 descriptors_cleanup(struct adist_host *adhost)
108 if (adh == adhost)
124 child_cleanup(struct adist_host *adhost)
127 if (adhost->adh_conn != NULL) {
128 PJDLOG_ASSERT(adhost->adh_role == ADIST_ROLE_SENDER);
129 proto_close(adhost->adh_conn);
130 adhost->adh_conn = NULL;
132 adhost->adh_worker_pid = 0;
154 struct adist_host *adhost;
162 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
163 if (pid == adhost->adh_worker_pid)
166 if (adhost == NULL) {
169 if (adhost->adh_role == ADIST_ROLE_SENDER)
171 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
172 role2str(adhost->adh_role));
174 child_cleanup(adhost);
182 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
183 if (adhost->adh_role != ADIST_ROLE_SENDER)
185 if (adhost->adh_worker_pid != 0)
187 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
188 role2str(adhost->adh_role));
190 adist_sender(adcfg, adhost);
206 struct adist_host *adhost;
209 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
210 if (adhost->adh_worker_pid == 0)
212 pjdlog_info("Terminating worker process (adhost=%s, role=%s, pid=%u).",
213 adhost->adh_name, role2str(adhost->adh_role),
214 adhost->adh_worker_pid);
215 if (kill(adhost->adh_worker_pid, SIGTERM) == 0)
218 "Unable to send signal to worker process (adhost=%s, role=%s, pid=%u).",
219 adhost->adh_name, role2str(adhost->adh_role),
220 adhost->adh_worker_pid);
228 struct adist_host *adhost;
256 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
257 if (adhost->adh_role != ADIST_ROLE_RECEIVER)
259 if (!proto_address_match(conn, adhost->adh_remoteaddr))
263 if (adhost == NULL) {
274 adhost->adh_remoteaddr);
280 adhost->adh_remoteaddr);
290 adhost->adh_remoteaddr);
294 if (proto_recv(conn, adname, sizeof(adhost->adh_name)) < 0) {
301 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
302 if (adhost->adh_role != ADIST_ROLE_RECEIVER)
304 if (!proto_address_match(conn, adhost->adh_remoteaddr))
306 if (strcmp(adhost->adh_name, adname) != 0)
310 if (adhost == NULL) {
316 adhost->adh_version = version;
317 pjdlog_debug(1, "Version %d negotiated with %s.", adhost->adh_version,
318 adhost->adh_remoteaddr);
321 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
322 role2str(adhost->adh_role));
332 adhost->adh_remoteaddr);
339 adhost->adh_remoteaddr);
344 if (HMAC(EVP_sha256(), adhost->adh_password,
345 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
354 adhost->adh_remoteaddr);
361 adhost->adh_remoteaddr);
366 if (HMAC(EVP_sha256(), adhost->adh_password,
367 (int)strlen(adhost->adh_password), rnd, (int)sizeof(rnd), hash,
376 adhost->adh_remoteaddr);
381 if (adhost->adh_worker_pid != 0) {
384 (unsigned int)adhost->adh_worker_pid);
386 if (kill(adhost->adh_worker_pid, SIGINT) == -1) {
389 (unsigned int)adhost->adh_worker_pid);
396 else if ((pid = waitpid(adhost->adh_worker_pid,
397 &status, 0)) != adhost->adh_worker_pid) {
401 (unsigned int)adhost->adh_worker_pid);
403 child_exit_log("Worker", adhost->adh_worker_pid,
406 child_cleanup(adhost);
409 adhost->adh_remote = conn;
410 adist_receiver(adcfg, adhost);
420 connection_migrate(struct adist_host *adhost)
425 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
426 role2str(adhost->adh_role));
428 PJDLOG_ASSERT(adhost->adh_role == ADIST_ROLE_SENDER);
430 if (proto_recv(adhost->adh_conn, &val, sizeof(val)) < 0) {
435 if (proto_set("tls:fingerprint", adhost->adh_fingerprint) == -1) {
440 if (proto_connect(adhost->adh_localaddr[0] != '\0' ?
441 adhost->adh_localaddr : NULL,
442 adhost->adh_remoteaddr, -1, &conn) < 0) {
445 adhost->adh_remoteaddr);
450 if (proto_send(adhost->adh_conn, &val, sizeof(val)) < 0) {
454 if (val == 0 && proto_connection_send(adhost->adh_conn, conn) < 0)
499 struct adist_host *adhost;
524 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
525 if (adhost->adh_role == ADIST_ROLE_SENDER) {
527 PJDLOG_ASSERT(adhost->adh_conn != NULL);
528 fd = proto_descriptor(adhost->adh_conn);
533 PJDLOG_ASSERT(adhost->adh_conn == NULL);
565 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
566 if (adhost->adh_role == ADIST_ROLE_SENDER) {
567 PJDLOG_ASSERT(adhost->adh_conn != NULL);
568 if (FD_ISSET(proto_descriptor(adhost->adh_conn),
570 connection_migrate(adhost);
573 PJDLOG_ASSERT(adhost->adh_conn == NULL);
582 struct adist_host *adhost;
599 TAILQ_FOREACH(adhost, &cfg->adc_hosts, adh_next) {
600 pjdlog_debug(2, " name: %s", adhost->adh_name);
601 pjdlog_debug(2, " role: %s", role2str(adhost->adh_role));
602 pjdlog_debug(2, " version: %d", adhost->adh_version);
603 pjdlog_debug(2, " localaddr: %s", adhost->adh_localaddr);
604 pjdlog_debug(2, " remoteaddr: %s", adhost->adh_remoteaddr);
605 pjdlog_debug(2, " remote: %p", adhost->adh_remote);
606 pjdlog_debug(2, " directory: %s", adhost->adh_directory);
607 pjdlog_debug(2, " compression: %d", adhost->adh_compression);
608 pjdlog_debug(2, " checksum: %d", adhost->adh_checksum);
609 pjdlog_debug(2, " pid: %ld", (long)adhost->adh_worker_pid);
610 pjdlog_debug(2, " conn: %p", adhost->adh_conn);
623 struct adist_host *adhost;
790 TAILQ_FOREACH(adhost, &adcfg->adc_hosts, adh_next) {
791 if (adhost->adh_role == ADIST_ROLE_SENDER)
792 adist_sender(adcfg, adhost);