~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/slurmdbd/rpc_mgr.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *  Copyright (C) 2008 Lawrence Livermore National Security.
6
6
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7
7
 *  Written by Morris Jette <jette1@llnl.gov>
8
 
 *  LLNL-CODE-402394.
 
8
 *  CODE-OCEC-09-009. All rights reserved.
9
9
 *  
10
10
 *  This file is part of SLURM, a resource management program.
11
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
11
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
12
 *  Please also read the included file: DISCLAIMER.
12
13
 *  
13
14
 *  SLURM is free software; you can redistribute it and/or modify it under
14
15
 *  the terms of the GNU General Public License as published by the Free
62
63
 
63
64
/* Local functions */
64
65
static bool   _fd_readable(slurm_fd fd);
65
 
static bool   _fd_writeable(slurm_fd fd);
66
66
static void   _free_server_thread(pthread_t my_tid);
67
67
static int    _send_resp(slurm_fd fd, Buf buffer);
68
68
static void * _service_connection(void *arg);
273
273
        ssize_t msg_wrote;
274
274
        char *out_buf;
275
275
 
276
 
        if ((fd < 0) || (!_fd_writeable(fd)))
 
276
        if ((fd < 0) || (!fd_writeable(fd)))
277
277
                goto io_err;
278
278
 
279
279
        msg_size = get_buf_offset(buffer);
280
280
        nw_size = htonl(msg_size);
281
 
        if (!_fd_writeable(fd))
 
281
        if (!fd_writeable(fd))
282
282
                goto io_err;
283
283
        msg_wrote = write(fd, &nw_size, sizeof(nw_size));
284
284
        if (msg_wrote != sizeof(nw_size))
286
286
 
287
287
        out_buf = get_buf_data(buffer);
288
288
        while (msg_size > 0) {
289
 
                if (!_fd_writeable(fd))
 
289
                if (!fd_writeable(fd))
290
290
                        goto io_err;
291
291
                msg_wrote = write(fd, out_buf, msg_size);
292
292
                if (msg_wrote <= 0)
355
355
 
356
356
/* Wait until a file is writeable, 
357
357
 * RET false if can not be written to within 5 seconds */
358
 
static bool _fd_writeable(slurm_fd fd)
 
358
extern bool fd_writeable(slurm_fd fd)
359
359
{
360
360
        struct pollfd ufds;
361
361
        int msg_timeout = 5000;
362
362
        int rc, time_left;
363
363
        struct timeval tstart;
 
364
        char temp[2];
364
365
 
365
366
        ufds.fd     = fd;
366
367
        ufds.events = POLLOUT;
367
368
        gettimeofday(&tstart, NULL);
368
 
        while (1) {
 
369
        while (shutdown_time == 0) {
369
370
                time_left = msg_timeout - _tot_wait(&tstart);
370
371
                rc = poll(&ufds, 1, time_left);
371
372
                if (shutdown_time)
377
378
                        return false;
378
379
                }
379
380
                if (rc == 0) {
380
 
                        error("write timeout");
 
381
                        debug2("write timeout");
381
382
                        return false;
382
383
                }
383
 
                if (ufds.revents & POLLHUP) {
 
384
 
 
385
                /*
 
386
                 * Check here to make sure the socket really is there.
 
387
                 * If not then exit out and notify the sender.  This
 
388
                 * is here since a write doesn't always tell you the
 
389
                 * socket is gone, but getting 0 back from a
 
390
                 * nonblocking read means just that. 
 
391
                 */
 
392
                if (ufds.revents & POLLHUP || (recv(fd, &temp, 1, 0) == 0)) {
384
393
                        debug3("Write connection %d closed", fd);
385
394
                        return false;
386
395
                }