~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to cygnal/libnet/network.cpp

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-03-04 03:19:06 UTC
  • mfrom: (1.1.18) (3.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120304031906-p6q5rnb0xhgpof7o
Tags: 0.8.10-3ubuntu1
* Merge from Debian testing (FFe: LP: #940876), remaining changes:
  - Use mozilla-flashplugin as the alternative for now
  - Change xulrunner-dev build dep to firefox-dev
* Drop the plugin API porting patch, this has been fixed upstream
  - drop debian/patches*
* Drop the following change as we want Adobe's player to take priority
  if it's installed
  - Set alternative priority to 50 so that it matches Adobe Flash's priority

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3
 
//   2011 Free Software Foundation, Inc
 
2
//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 
3
//   Free Software Foundation, Inc
4
4
//
5
5
// This program is free software; you can redistribute it and/or modify
6
6
// it under the terms of the GNU General Public License as published by
159
159
    int             retries = 0;
160
160
 
161
161
    if (_listenfd >= 2) {
162
 
        log_debug("already connected to port %hd", port);
 
162
        log_debug(_("already connected to port %hd"), port);
163
163
        return _listenfd;
164
164
    }
165
165
    
323
323
            ret = pselect(fd+1, &fdset, NULL, NULL, &tval, &blockset);
324
324
        }
325
325
        if (sig_number) {
326
 
            log_debug("Have a SIGINT interupt waiting!");
 
326
            log_debug("Have a SIGINT interrupt waiting!");
327
327
        }
328
328
        sigpending(&pending);
329
329
        if (sigismember(&pending, SIGINT)) {
330
 
            log_debug("Have a pending SIGINT interupt waiting!");
 
330
            log_debug("Have a pending SIGINT interrupt waiting!");
331
331
            int sig;
332
332
            sigwait(&blockset, &sig);
333
333
        }
334
334
        if (sigismember(&pending, SIGPIPE)) {
335
 
            log_debug("Have a pending SIGPIPE interupt waiting!");
 
335
            log_debug("Have a pending SIGPIPE interrupt waiting!");
336
336
            int sig;
337
337
            sigwait(&blockset, &sig);
338
338
        }
359
359
        }
360
360
 
361
361
        if (ret == -1) {
362
 
            log_debug(_("The accept() socket for fd #%d never was available"), fd);
 
362
            log_debug("The accept() socket for fd #%d never was available", fd);
363
363
            return -1;
364
364
        }
365
365
 
366
366
        if (ret == 0) {
367
367
            if (_debug) {
368
 
                log_debug(_("The accept() socket for fd #%d timed out waitingfor data"), fd);
 
368
                log_debug("The accept() socket for fd #%d timed out"
 
369
                    " waitingfor data", fd);
369
370
                return 0;
370
371
            }
371
372
        }
383
384
    }
384
385
 
385
386
    if (_debug) {
386
 
        log_debug(_("Accepting tcp/ip connection on fd #%d for port %d"), _sockfd, _port);
 
387
        log_debug(_("Accepting TCP/IP connection on fd #%d for port %d"), _sockfd, _port);
387
388
    }
388
389
 
389
390
    return _sockfd;
763
764
 
764
765
    if (fd > 0) {
765
766
        ::close(fd);
766
 
        log_debug("%s: Closed fd #%d", __FUNCTION__, fd);
 
767
        log_debug(_("%s: Closed fd #%d"), __FUNCTION__, fd);
767
768
//        closeNet(fd);
768
769
    }
769
770
 
875
876
//     boost::mutex::scoped_lock lock(_net_mutex);
876
877
 
877
878
    if (_debug) {
878
 
        log_debug (_("Trying to read %d bytes from fd #%d"), nbytes, fd);
 
879
        log_debug(_("Trying to read %d bytes from fd #%d"), nbytes, fd);
879
880
    }
880
881
#ifdef NET_TIMING
881
882
    if (_timing_debug)
919
920
            ret = pselect(fd+1, &fdset, NULL, NULL, &tval, &blockset);
920
921
            sigpending(&pending);
921
922
            if (sigismember(&pending, SIGINT)) {
922
 
                log_debug("Have a pending SIGINT interupt waiting!");
 
923
                log_debug("Have a pending SIGINT interrupt waiting!");
923
924
                int sig;
924
925
                sigwait(&blockset, &sig);
925
926
                cntrlc_handler(SIGINT);
926
927
            }
927
928
            if (sigismember(&pending, SIGPIPE)) {
928
 
                log_debug("Have a pending SIGPIPE interupt waiting!");
 
929
                log_debug("Have a pending SIGPIPE interrupt waiting!");
929
930
                int sig;
930
931
                sigwait(&blockset, &sig);
931
932
                cntrlc_handler(SIGINT);
939
940
 
940
941
        // If interrupted by a system call, try again
941
942
        if (ret == -1 && errno == EINTR) {
942
 
            log_error (_("The socket for fd #%d was interrupted by a system call"), fd);
 
943
            log_error(_("The socket for fd #%d was interrupted by a system call"), fd);
943
944
        }
944
945
 
945
946
        if (ret == -1) {
946
 
            log_error (_("The socket for fd #%d was never available for reading"), fd);
 
947
            log_error(_("The socket for fd #%d was never available for reading"), fd);
947
948
            return -1;
948
949
        }
949
950
 
950
951
        if (ret == 0) {
951
952
            if (_debug) {
952
 
                log_debug (_("The socket for #fd %d timed out waiting to read"), fd);
 
953
                log_debug(_("The socket for #fd %d timed out waiting to read"), fd);
953
954
            }
954
955
            return 0;
955
956
        }
966
967
 
967
968
        // If we read zero bytes, the network may be closed, as we returned from the select()
968
969
        if (ret == -1) {
969
 
            log_error (_("The socket for fd #%d was never available for reading data"), fd);
 
970
            log_error(_("The socket for fd #%d was never available for reading data"), fd);
970
971
            return -1;
971
972
        }
972
973
 
1100
1101
        ret = pselect(fd+1, NULL, &fdset, NULL, &tval, &blockset);
1101
1102
        sigpending(&pending);
1102
1103
        if (sigismember(&pending, SIGINT)) {
1103
 
            log_debug("Have a pending SIGINT interupt waiting!");
 
1104
            log_debug("Have a pending SIGINT interrupt waiting!");
1104
1105
            int sig;
1105
1106
            sigwait(&blockset, &sig);
1106
1107
            cntrlc_handler(SIGINT);
1190
1191
{
1191
1192
//    GNASH_REPORT_FUNCTION;
1192
1193
 
1193
 
    log_debug("%s: adding fd #%d to pollfds", __PRETTY_FUNCTION__, fd.fd);
 
1194
    log_debug(_("%s: adding fd #%d to pollfds"), __PRETTY_FUNCTION__, fd.fd);
1194
1195
    boost::mutex::scoped_lock lock(_poll_mutex);
1195
1196
    _handlers[fd.fd] = func;
1196
1197
     _pollfds.push_back(fd);
1201
1202
Network::addPollFD(struct pollfd &fd)
1202
1203
{
1203
1204
//    GNASH_REPORT_FUNCTION;
1204
 
    log_debug("%s: adding fd #%d to pollfds", __PRETTY_FUNCTION__, fd.fd);
 
1205
    log_debug(_("%s: adding fd #%d to pollfds"), __PRETTY_FUNCTION__, fd.fd);
1205
1206
    boost::mutex::scoped_lock lock(_poll_mutex);
1206
1207
     _pollfds.push_back(fd);
1207
1208
//     notify();
1227
1228
Network::erasePollFD(int fd)
1228
1229
{
1229
1230
//    GNASH_REPORT_FUNCTION;
1230
 
    log_debug("%s: erasing fd #%d from pollfds", __PRETTY_FUNCTION__, fd);
 
1231
    log_debug(_("%s: erasing fd #%d from pollfds"), __PRETTY_FUNCTION__, fd);
1231
1232
    boost::mutex::scoped_lock lock(_poll_mutex);
1232
1233
    if (_pollfds.size() > 0) {
1233
1234
        vector<struct pollfd>::iterator it;
1275
1276
 
1276
1277
    boost::shared_ptr<vector<struct pollfd> > hits(new vector<struct pollfd>);
1277
1278
 
1278
 
    log_debug("%s: waiting for %d fds", __FUNCTION__, limit);
 
1279
    log_debug(_("%s: waiting for %d fds"), __FUNCTION__, limit);
1279
1280
 
1280
1281
    if ((fds == 0) || (limit == 0)) {
1281
1282
        return hits;
1298
1299
        int ret = ppoll(fds, limit, &tval, &blockset);
1299
1300
        sigpending(&pending);
1300
1301
        if (sigismember(&pending, SIGINT)) {
1301
 
            log_debug("Have a pending SIGINT interupt waiting!");
 
1302
            log_debug("Have a pending SIGINT interrupt waiting!");
1302
1303
            int sig;
1303
1304
            sigwait(&blockset, &sig);
1304
1305
        }
1314
1315
#endif
1315
1316
#endif
1316
1317
 
1317
 
    log_debug("Poll returned: %d, timeout is: %d", ret, _timeout);
 
1318
        log_debug(_("Poll returned: %d, timeout is: %d"), ret, _timeout);
1318
1319
 
1319
1320
    while (ret--) {
1320
1321
        for (int i = 0; i<limit; i++) {
1428
1429
    int ret = pselect(limit+1, &fdset, NULL, NULL, &tval, &sigmask);
1429
1430
    sigpending(&pending);
1430
1431
    if (sigismember(&pending, SIGINT)) {
1431
 
        log_debug("Have a pending SIGINT interupt waiting!");
 
1432
        log_debug("Have a pending SIGINT interrupt waiting!");
1432
1433
        int sig;
1433
1434
        sigwait(&sigmask, &sig);
1434
1435
    }
1435
1436
    if (sigismember(&pending, SIGPIPE)) {
1436
 
        log_debug("Have a pending SIGPIPE interupt waiting!");
 
1437
        log_debug("Have a pending SIGPIPE interrupt waiting!");
1437
1438
        int sig;
1438
1439
        sigwait(&sigmask, &sig);
1439
1440
    }
1463
1464
    }
1464
1465
 
1465
1466
    if (ret < 0) {
1466
 
        log_error("select() got an error: %s.", strerror(errno));
 
1467
        log_error(_("select() got an error: %s."), strerror(errno));
1467
1468
        FD_ZERO(&fdset);
1468
1469
        FD_SET(0, &fdset);
1469
1470
    } else {
1470
 
        log_network("select() saw activity on %d file descriptors.", ret);
 
1471
        log_network(_("select() saw activity on %d file descriptors."), ret);
1471
1472
    }
1472
1473
 
1473
1474
    return fdset;
1543
1544
 
1544
1545
    if (_sockfd == 0) {
1545
1546
        if ((_sockfd = createClient(hostname, SSL_PORT) == false)) {
1546
 
            log_error("Can't connect to server %s", hostname);
 
1547
            log_error(_("Can't connect to server %s"), hostname);
1547
1548
            return false;
1548
1549
        }
1549
1550
    }
1555
1556
    if (!hostname.empty()) {
1556
1557
        _ssl->setHostname(hostname);
1557
1558
    } else {
1558
 
        log_debug("Using default hostname: \"%s\"", _host);
 
1559
        log_debug(_("Using default hostname: \"%s\""), _host);
1559
1560
    }
1560
1561
    if (!keyfile.empty()) {
1561
1562
        _ssl->setKeyfile(keyfile);
1562
1563
    } else {
1563
 
        log_debug("Using default keyfile: \"%s\"", _ssl->getKeyfile());
 
1564
        log_debug(_("Using default keyfile: \"%s\""), _ssl->getKeyfile());
1564
1565
    }
1565
1566
    if (!calist.empty()) {
1566
1567
        _ssl->setCAlist(calist);
1567
1568
    } else {
1568
 
        log_debug("Using default CA List: \"%s\"", _ssl->getCAlist());
 
1569
        log_debug(_("Using default CA List: \"%s\""), _ssl->getCAlist());
1569
1570
    }
1570
1571
 
1571
1572
    if (!passwd.empty()) {
1572
1573
        _ssl->setPassword(passwd);
1573
1574
    } else {
1574
 
        log_debug("Using default Password: \"%s\"", _ssl->getPassword());
 
1575
        log_debug(_("Using default Password: \"%s\""), _ssl->getPassword());
1575
1576
    }
1576
1577
    if (!rootpath.empty()) {
1577
1578
        _ssl->setRootPath(rootpath);
1578
1579
    } else {
1579
 
        log_debug("Using default Root Path to PEM files: \"%s\"",
 
1580
        log_debug(_("Using default Root Path to PEM files: \"%s\""),
1580
1581
                  _ssl->getRootPath());
1581
1582
    }
1582
1583
 
1583
1584
    if (_ssl->sslConnect(_sockfd)) {
1584
 
        log_debug("Connected to SSL server");
 
1585
        log_debug(_("Connected to SSL server"));
1585
1586
    } else {
1586
 
        log_error("Couldn't connect to SSL server");
 
1587
        log_error(_("Couldn't connect to SSL server"));
1587
1588
        return false;
1588
1589
    }
1589
1590
 
1616
1617
        }
1617
1618
    }
1618
1619
 
1619
 
    log_network("#%d bytes waiting in kernel network buffer.", bytes);
 
1620
    log_network(_("#%d bytes waiting in kernel network buffer."), bytes);
1620
1621
    
1621
1622
    return bytes;
1622
1623
}
1635
1636
 
1636
1637
// Local Variables:
1637
1638
// mode: C++
1638
 
// indent-tabs-mode: t
 
1639
// indent-tabs-mode: nil
1639
1640
// End: