~ubuntu-branches/debian/squeeze/netatalk/squeeze

« back to all changes in this revision

Viewing changes to etc/cnid_dbd/cnid_metad.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-02-02 19:59:05 UTC
  • mfrom: (8.2.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090202195905-732t6wxk8jzsb91r
Tags: 2.0.4~beta2-4.1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes: LP: #318665
  - Changed dependency from libdb-dev to libdb4.6-dev to correct
    FTBFS due to an issue caused by mismatches on installed binaries
    and development headers (db4.7 is installed under a different soname
    which breaks a check in netatalk) (LP: #262991)
  - debian/control:
    + Replace libltdl3-dev with libltdl7-dev.
    + Recommend db4.6-util instead of db4.2-util as we build netatalk with
      db4.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: cnid_metad.c,v 1.1.4.15 2004/09/06 07:19:21 didg Exp $
 
2
 * $Id: cnid_metad.c,v 1.1.4.15.2.3 2008/08/31 09:52:14 didg Exp $
3
3
 *
4
4
 * Copyright (C) Joerg Lenneis 2003
5
5
 * All Rights Reserved.  See COPYING.
40
40
#include <sys/socket.h>
41
41
#include <stdio.h>
42
42
#include <time.h>
43
 
 
 
43
#include <sys/ioctl.h>
 
44
  
44
45
#ifndef WEXITSTATUS 
45
46
#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
46
47
#endif /* ! WEXITSTATUS */
92
93
 
93
94
static int srvfd;
94
95
static int rqstfd;
 
96
volatile sig_atomic_t alarmed = 0;
95
97
 
96
98
#define MAXSRV 128
97
99
 
114
116
 
115
117
static struct server srv[MAXSRV +1];
116
118
 
117
 
static struct server *test_usockfn(char *dir, char *fn)
 
119
static struct server *test_usockfn(char *dir, char *fn _U_)
118
120
{
119
121
int i;
120
122
    for (i = 1; i <= MAXSRV; i++) {
363
365
}
364
366
 
365
367
/* ------------------ */
 
368
void catch_alarm(int sig) {
 
369
        alarmed = 1;
 
370
}
 
371
 
 
372
/* ------------------ */
366
373
int main(int argc, char *argv[])
367
374
{
368
375
    char  dbdir[MAXPATHLEN + 1];
369
 
    int   len;
 
376
    int   len, actual_len;
370
377
    pid_t pid;
371
378
    int   status;
372
379
    char  *dbdpn = _PATH_CNID_DBD;
472
479
    }
473
480
 
474
481
    signal(SIGPIPE, SIG_IGN);
 
482
    signal(SIGALRM, catch_alarm);
475
483
 
476
484
    while (1) {
477
485
        rqstfd = usockfd_check(srvfd, 10000000);
500
508
        }
501
509
        if (rqstfd <= 0)
502
510
            continue;
 
511
 
503
512
        /* TODO: Check out read errors, broken pipe etc. in libatalk. Is
504
513
           SIGIPE ignored there? Answer: Ignored for dsi, but not for asp ... */
 
514
        alarm(5); /* to prevent read from getting stuck */
505
515
        ret = read(rqstfd, &len, sizeof(int));
 
516
        alarm(0);
 
517
        if (alarmed) {
 
518
            alarmed = 0;
 
519
            LOG(log_severe, logtype_cnid, "Read(1) bailed with alarm (timeout)");
 
520
            goto loop_end;
 
521
        }
 
522
        
506
523
        if (!ret) {
507
524
            /* already close */
508
525
            goto loop_end;
523
540
            LOG(log_error, logtype_cnid, "wrong len parameter: %d", len);
524
541
            goto loop_end;
525
542
        }
526
 
        if (read(rqstfd, dbdir, len) != len) {
 
543
        
 
544
        alarm(5);
 
545
        actual_len = read(rqstfd, dbdir, len);
 
546
        alarm(0);
 
547
        if (alarmed) {
 
548
            alarmed = 0;
 
549
            LOG(log_severe, logtype_cnid, "Read(2) bailed with alarm (timeout)");
 
550
            goto loop_end;
 
551
        }
 
552
        if (actual_len != len) {
527
553
            LOG(log_error, logtype_cnid, "error/short read (dir): %s", strerror(errno));
528
554
            goto loop_end;
529
555
        }