Lines Matching defs:adhost
90 static struct adist_host *adhost;
219 if (proto_recv(adhost->adh_remote, &adreq->adr_packet,
238 adhost->adh_directory, adhost->adh_trail_name);
249 if (proto_recv(adhost->adh_remote, adreq->adr_data,
286 if (adhost->adh_trail_fd != -1) {
288 filename, adhost->adh_trail_name);
298 switch (trail_name_compare(filename, adhost->adh_trail_name)) {
300 if (!trail_is_not_terminated(adhost->adh_trail_name)) {
302 adhost->adh_directory, adhost->adh_trail_name,
303 adhost->adh_directory, filename);
306 if (renameat(adhost->adh_trail_dirfd, adhost->adh_trail_name,
307 adhost->adh_trail_dirfd, filename) == -1) {
310 adhost->adh_directory, adhost->adh_trail_name,
311 adhost->adh_directory, filename);
316 adhost->adh_directory, adhost->adh_trail_name,
317 adhost->adh_directory, filename);
321 fd = openat(adhost->adh_trail_dirfd, filename,
326 adhost->adh_directory, filename);
331 adhost->adh_directory, filename);
335 fd = openat(adhost->adh_trail_dirfd, filename,
340 adhost->adh_directory, filename);
345 adhost->adh_directory, filename);
354 PJDLOG_VERIFY(strlcpy(adhost->adh_trail_name, filename,
355 sizeof(adhost->adh_trail_name)) < sizeof(adhost->adh_trail_name));
356 adhost->adh_trail_fd = fd;
370 if (adhost->adh_trail_fd == -1) {
377 done = write(adhost->adh_trail_fd, data, size);
382 adhost->adh_directory, adhost->adh_trail_name);
387 adhost->adh_directory, adhost->adh_trail_name);
391 osize, adhost->adh_directory, adhost->adh_trail_name);
400 if (adhost->adh_trail_fd == -1) {
406 if (!trail_validate_name(adhost->adh_trail_name, filename)) {
408 adhost->adh_trail_name, filename);
412 PJDLOG_VERIFY(close(adhost->adh_trail_fd) == 0);
413 adhost->adh_trail_fd = -1;
415 pjdlog_debug(1, "Closed file \"%s/%s\".", adhost->adh_directory,
416 adhost->adh_trail_name);
418 if (strcmp(adhost->adh_trail_name, filename) == 0) {
423 if (renameat(adhost->adh_trail_dirfd, adhost->adh_trail_name,
424 adhost->adh_trail_dirfd, filename) == -1) {
426 adhost->adh_trail_name, filename);
431 adhost->adh_directory, adhost->adh_trail_name,
432 adhost->adh_directory, filename);
433 PJDLOG_VERIFY(strlcpy(adhost->adh_trail_name, filename,
434 sizeof(adhost->adh_trail_name)) < sizeof(adhost->adh_trail_name));
444 if (adhost->adh_trail_fd == -1) {
449 PJDLOG_VERIFY(close(adhost->adh_trail_fd) == 0);
450 adhost->adh_trail_fd = -1;
452 pjdlog_debug(1, "Closed file \"%s/%s\".", adhost->adh_directory,
453 adhost->adh_trail_name);
516 if (proto_send(adhost->adh_remote, &adrep,
551 if (mkdir(adhost->adh_directory, 0700) == -1) {
553 adhost->adh_directory);
555 if (chown(adhost->adh_directory, pw->pw_uid, pw->pw_gid) == -1) {
558 adhost->adh_directory);
559 (void)rmdir(adhost->adh_directory);
569 adhost->adh_trail_dirfd = open(adhost->adh_directory,
571 if (adhost->adh_trail_dirfd == -1) {
574 adhost->adh_trail_dirfd = open(adhost->adh_directory,
577 if (adhost->adh_trail_dirfd == -1) {
580 adhost->adh_directory);
583 adhost->adh_trail_dirfp = fdopendir(adhost->adh_trail_dirfd);
584 if (adhost->adh_trail_dirfp == NULL) {
586 adhost->adh_directory);
591 if (stat(adhost->adh_directory, &sb) == -1) {
597 adhost->adh_directory);
600 adhost->adh_trail_dirfp = opendir(adhost->adh_directory);
601 if (adhost->adh_trail_dirfp == NULL) {
603 adhost->adh_directory);
605 adhost->adh_trail_dirfd = dirfd(adhost->adh_trail_dirfp);
615 PJDLOG_ASSERT(adhost->adh_trail_dirfp != NULL);
617 trail_last(adhost->adh_trail_dirfp, adhost->adh_trail_name,
618 sizeof(adhost->adh_trail_name));
620 if (adhost->adh_trail_name[0] == '\0') {
623 if (fstatat(adhost->adh_trail_dirfd, adhost->adh_trail_name,
626 adhost->adh_directory, adhost->adh_trail_name);
631 adhost->adh_directory, adhost->adh_trail_name);
636 if (proto_send(adhost->adh_remote, &trail_size,
641 if (proto_send(adhost->adh_remote, adhost->adh_trail_name,
642 sizeof(adhost->adh_trail_name)) == -1) {
673 adhost = adh;
677 descriptors_cleanup(adhost);
679 // descriptors_assert(adhost, mode);
683 pjdlog_prefix_set("[%s] (%s) ", adhost->adh_name,
684 role2str(adhost->adh_role));
686 setproctitle("%s (%s)", adhost->adh_name, role2str(adhost->adh_role));
693 if (proto_timeout(adhost->adh_remote, adcfg->adc_timeout) == -1)
698 adhost->adh_trail_fd = -1;
702 role2str(adhost->adh_role), adhost->adh_name) != 0) {
709 error = pthread_create(&td, NULL, recv_thread, adhost);
711 error = pthread_create(&td, NULL, disk_thread, adhost);
713 (void)send_thread(adhost);