~vanvugt/+junk/mediatomb

« back to all changes in this revision

Viewing changes to tombupnp/upnp/src/genlib/net/sock.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2008-03-02 13:09:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080302130916-zlljdze3kt7vuq4b
Tags: 0.11.0-1
* New upstream release.
* Include message about which inotify headers will be used when enabling
  inotify runtime support.
* Fixed error with use of INTERFACE in init script. Also removed use of -m
  option.
* Including new config.xml options.
* Added more build dependencies for new upstream release.
* Removed build dependency of libid3-dev, taglib is now preferred.
* mediatomb.xpm and manpage.xml is now included in orig tarball.
* inotify patch is not needed anymore.
* md5 patch has been committed upstream and is no longer needed. Also removed
  README.Debian.
* TwinHelix PNG fix is now used. Removed from TODO.
* Adding dependency of iceweasel for mediatomb package.
* Updated copyright file.
* Updated watch file.
* Updated rules file for proper configure options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    
33
33
    TombUPnP - a library for developing UPnP applications.
34
34
    
35
 
    Copyright (C) 2006-2007 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
 
35
    Copyright (C) 2006-2008 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
36
36
    
37
37
    This library is free software; you can redistribute it and/or
38
38
    modify it under the terms of the GNU Lesser General Public
46
46
    You should have received a copy of the GNU Lesser General Public
47
47
    License along with this library; if not, write to the Free Software
48
48
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
49
    
 
50
    $Id: sock.c 1698 2008-02-23 20:48:30Z lww $
49
51
*/
50
52
 
51
53
/************************************************************************
57
59
#include <errno.h>
58
60
#include <time.h>
59
61
#include <string.h>
 
62
#include <poll.h>
60
63
 
61
64
#include "sock.h"
62
65
#include "upnp.h"
398
401
    return num_bytes;
399
402
}
400
403
 
 
404
// checks if writing to the socket is possible
 
405
int
 
406
sock_check_w( IN SOCKINFO * info )
 
407
{
 
408
    fd_set readSet;
 
409
    fd_set exceptSet;
 
410
    struct timeval timeout;
 
411
 
 
412
    int retCode;
 
413
    int sockfd = info->socket;
 
414
 
 
415
    FD_ZERO(&readSet);
 
416
    FD_ZERO(&exceptSet);
 
417
    FD_SET(sockfd, &readSet);
 
418
    FD_SET(sockfd, &exceptSet);
 
419
 
 
420
    timeout.tv_sec = 1; // 1 second select, we do not care if it times out
 
421
                        // we only look for an error
 
422
    timeout.tv_usec = 0;
 
423
 
 
424
    retCode = select(sockfd + 1, &readSet, NULL, &exceptSet, &timeout);
 
425
    
 
426
    if (FD_ISSET(sockfd, &readSet) || FD_ISSET(sockfd, &exceptSet))
 
427
    {
 
428
        return 0;
 
429
    }
 
430
 
 
431
    if (retCode >= 0) // timeout or fd ready for writing
 
432
        return 1;
 
433
 
 
434
    if (retCode == -1)
 
435
    {
 
436
        if(errno == EINTR)
 
437
            return 1;
 
438
    }
 
439
 
 
440
    return 0;
 
441
}
 
442
 
401
443
/************************************************************************
402
444
*       Function :      sock_write
403
445
*
436
478
        return UPNP_E_TIMEDOUT;
437
479
    }
438
480
 
439
 
    FD_ZERO(&writeSet);
440
 
    FD_SET(sockfd, &writeSet);
441
 
 
442
 
    timeout.tv_sec = *timeoutSecs;
443
 
    timeout.tv_usec = 0;
444
 
 
445
481
    while (TRUE)
446
482
    {
 
483
        FD_ZERO(&writeSet);
 
484
        FD_SET(sockfd, &writeSet);
 
485
 
447
486
        timeout.tv_sec = *timeoutSecs;
448
487
        timeout.tv_usec = 0;
449
488
 
469
508
                    return UPNP_E_TIMEDOUT;
470
509
            }
471
510
 
472
 
            FD_ZERO(&writeSet);
473
 
            FD_SET(sockfd, &writeSet);
474
 
 
475
511
            continue;
476
512
        }
477
513