~ubuntu-branches/ubuntu/oneiric/libupnp4/oneiric-updates

« back to all changes in this revision

Viewing changes to upnp/src/genlib/miniserver/miniserver.c

  • Committer: Bazaar Package Importer
  • Author(s): Nick Leverton
  • Date: 2010-05-14 15:34:11 UTC
  • mfrom: (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100514153411-9i238idmkyg7j00y
Tags: 1.8.0~svn20100507-1
* New pull from upstream subversion
* Fixes to BSD build issues (Closes: #573321, FTBFS on Gnu/kFreeBSD)
* More debug tidying (07-neaten-debug.patch):
  - send UPNP_CRITICAL msgs to the info log as well as to the error log.
  - don't print HTTP headers to stdout as they're already in logfile.
* Always compile in logging code but don't log unless requested
  (12-debian-always-debug.patch) to help porting other apps.
* Remove patches 03, 04, 06, 08 and 10, now in upstream (note naming
  difference in upstream's string object accessors).
* Add $PTHREAD_CFLAGS to libupnp.pc as assumed by {acx,ax}_pthread.m4
  (patch 16, Closes: #581608).

Show diffs side-by-side

added added

removed removed

Lines of Context:
625
625
                                return UPNP_E_SOCKET_BIND;
626
626
                        }
627
627
 
628
 
                        sockError = bind(listenfd4, (struct sockaddr *)&__ss_v4, 
629
 
                                sizeof (__ss_v4));
 
628
                        serverAddr4->sin_port = htons(listen_port4);
 
629
                        sockError = bind(listenfd4, (struct sockaddr *)&__ss_v4, sizeof (__ss_v4));
630
630
                        if (sockError == -1) {
631
631
                                strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
632
632
                                UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
652
652
                                return UPNP_E_SOCKET_BIND;
653
653
                        }
654
654
 
 
655
                        serverAddr6->sin6_port = htons(listen_port6);
655
656
                        sockError = bind(listenfd6, (struct sockaddr *)&__ss_v6, sizeof (__ss_v6));
656
657
                        if (sockError == -1) {
657
658
                                strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
668
669
                }
669
670
        } else {
670
671
                if (listenfd4 != INVALID_SOCKET) {
 
672
                        unsigned short orig_listen_port4 = listen_port4;
671
673
                        do {
672
674
                                serverAddr4->sin_port = htons(listen_port4++);
673
 
                                sockError = bind(listenfd4, (struct sockaddr *)&__ss_v4, sizeof(__ss_v4));
 
675
                                sockError = bind(listenfd4, (struct sockaddr *)serverAddr4, sizeof(*serverAddr4));
674
676
                                if (sockError == -1) {
675
677
#ifdef WIN32
676
678
                                        errCode = WSAGetLastError();
683
685
                                } else {
684
686
                                        errCode = 0;
685
687
                                }
686
 
                        } while ( errCode != 0 );
 
688
                        } while ( errCode != 0 && (listen_port4 >= orig_listen_port4) );
687
689
 
688
690
                        if (sockError == -1) {
689
691
                                strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
699
701
                }
700
702
 
701
703
                if (listenfd6 != INVALID_SOCKET) {
 
704
                        unsigned short orig_listen_port6 = listen_port6;
702
705
                        do {
703
706
                                serverAddr6->sin6_port = htons(listen_port6++);
704
 
                                sockError = bind(listenfd6, (struct sockaddr *)&__ss_v6, sizeof(__ss_v6));
 
707
                                sockError = bind(listenfd6, (struct sockaddr *)serverAddr6, sizeof(*serverAddr6));
705
708
                                if (sockError == -1) {
706
709
#ifdef WIN32
707
710
                                        errCode = WSAGetLastError();
714
717
                                } else {
715
718
                                        errCode = 0;
716
719
                                }
717
 
                        } while (errCode != 0);
 
720
                        } while (errCode != 0 && (listen_port6 >= orig_listen_port6));
718
721
 
719
722
                        if (sockError == -1) {
720
723
                                strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);