~ubuntu-branches/ubuntu/karmic/cyrus-imapd-2.2/karmic

« back to all changes in this revision

Viewing changes to imap/mupdate.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-07-11 18:51:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060711185139-gl3oe4tppp7g3euf
Tags: 2.2.13-4ubuntu1
Synchronize with Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mupdate.c -- cyrus murder database master 
2
2
 *
3
 
 * $Id: mupdate.c,v 1.89 2004/12/17 16:32:16 ken3 Exp $
 
3
 * $Id: mupdate.c,v 1.92 2005/11/04 13:33:30 murch Exp $
4
4
 * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
5
5
 *
6
6
 * Redistribution and use in source and binary forms, with or without
460
460
    return 0;
461
461
}
462
462
 
 
463
 
 
464
/*
 
465
 * The auth_*.c backends called by mysasl_proxy_policy()
 
466
 * use static variables which we need to protect with a mutex.
 
467
 */
 
468
static pthread_mutex_t proxy_policy_mutex = PTHREAD_MUTEX_INITIALIZER;
 
469
 
 
470
static int mupdate_proxy_policy(sasl_conn_t *conn,
 
471
                                void *context,
 
472
                                const char *requested_user, unsigned rlen,
 
473
                                const char *auth_identity, unsigned alen,
 
474
                                const char *def_realm,
 
475
                                unsigned urlen,
 
476
                                struct propctx *propctx)
 
477
{
 
478
    int r;
 
479
 
 
480
    pthread_mutex_lock(&proxy_policy_mutex); /* LOCK */
 
481
 
 
482
    r = mysasl_proxy_policy(conn, context, requested_user, rlen,
 
483
                            auth_identity, alen, def_realm, urlen, propctx);
 
484
 
 
485
    pthread_mutex_unlock(&proxy_policy_mutex); /* UNLOCK */
 
486
 
 
487
    return r;
 
488
}
 
489
 
463
490
static struct sasl_callback mysasl_cb[] = {
464
491
    { SASL_CB_GETOPT, &mysasl_config, NULL },
465
 
    { SASL_CB_PROXY_POLICY, &mysasl_proxy_policy, NULL },
 
492
    { SASL_CB_PROXY_POLICY, &mupdate_proxy_policy, NULL },
466
493
    { SASL_CB_LIST_END, NULL, NULL }
467
494
};
468
495
 
949
976
        close(fd);
950
977
 
951
978
        syslog(LOG_ERR,
952
 
               "Server too busy, droping connection.");
 
979
               "Server too busy, dropping connection.");
953
980
    } else if(write(conn_pipe[1], &fd, sizeof(fd)) == -1) {
954
981
        /* signal that a new file descriptor is available.
955
982
         * If it fails... */
1045
1072
        if(!max_worker_flag) idle_worker_count++;
1046
1073
        pthread_mutex_unlock(&idle_worker_mutex);
1047
1074
 
1048
 
        if(max_worker_flag) {
1049
 
            pthread_mutex_unlock(&idle_worker_mutex);
1050
 
            goto worker_thread_done;
1051
 
        }
 
1075
        if(max_worker_flag) goto worker_thread_done;
1052
1076
 
1053
1077
    retry_lock:
1054
1078
 
1133
1157
        if(need_workers > 0) {
1134
1158
            too_many = (need_workers + worker_count) - 
1135
1159
                config_getint(IMAPOPT_MUPDATE_WORKERS_MAX);
1136
 
            need_workers -= too_many;
 
1160
            if (too_many > 0) need_workers -= too_many;
1137
1161
        }
1138
1162
        
1139
1163
        /* Do we need a new worker (or two, or three...)?