~ubuntu-branches/ubuntu/precise/corosync/precise-proposed

« back to all changes in this revision

Viewing changes to exec/totemudpu.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Loschwitz
  • Date: 2011-10-19 14:32:18 UTC
  • mfrom: (1.1.6 upstream) (5.1.16 sid)
  • Revision ID: james.westby@ubuntu.com-20111019143218-ew8phl0raqyog844
Tags: 1.4.2-1
* Changed my email address in debian/control
* Add corosync-blackbox to the corosync package
* Imported Upstream version 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
#include "totemudpu.h"
68
68
 
69
69
#include "crypto.h"
 
70
#include "util.h"
70
71
 
71
72
#ifdef HAVE_LIBNSS
72
73
#include <nss.h>
941
942
         */
942
943
        res = sendmsg (instance->token_socket, &msg_ucast, MSG_NOSIGNAL);
943
944
        if (res < 0) {
944
 
                char error_str[100];
945
 
                strerror_r (errno, error_str, sizeof(error_str));
946
 
                log_printf (instance->totemudpu_log_level_debug,
947
 
                                "sendmsg(ucast) failed (non-critical): %s\n", error_str);
 
945
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_debug,
 
946
                                "sendmsg(ucast) failed (non-critical)");
948
947
        }
949
948
}
950
949
 
1034
1033
                 */
1035
1034
                res = sendmsg (member->fd, &msg_mcast, MSG_NOSIGNAL);
1036
1035
                if (res < 0) {
1037
 
                        char error_str[100];
1038
 
                        strerror_r (errno, error_str, sizeof(error_str));
1039
 
                        log_printf (instance->totemudpu_log_level_debug,
1040
 
                                "sendmsg(mcast) failed (non-critical): %s\n", error_str);
 
1036
                        LOGSYS_PERROR (errno, instance->totemudpu_log_level_debug,
 
1037
                                "sendmsg(mcast) failed (non-critical)");
1041
1038
                }
1042
1039
        }
1043
1040
}
1283
1280
{
1284
1281
#ifdef SO_PRIORITY
1285
1282
        int prio = 6; /* TC_PRIO_INTERACTIVE */
1286
 
        char error_str[100];
1287
1283
 
1288
1284
        if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int))) {
1289
 
                strerror_r (errno, error_str, 100);
1290
 
                log_printf (instance->totemudpu_log_level_warning,
1291
 
                        "Could not set traffic priority. (%s)\n", error_str);
 
1285
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 
1286
                        "Could not set traffic priority");
1292
1287
    }
1293
1288
#endif
1294
1289
}
1310
1305
         */
1311
1306
        instance->token_socket = socket (bindnet_address->family, SOCK_DGRAM, 0);
1312
1307
        if (instance->token_socket == -1) {
1313
 
                perror ("socket2");
 
1308
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 
1309
                        "socket() failed");
1314
1310
                return (-1);
1315
1311
        }
1316
1312
 
1317
1313
        totemip_nosigpipe (instance->token_socket);
1318
1314
        res = fcntl (instance->token_socket, F_SETFL, O_NONBLOCK);
1319
1315
        if (res == -1) {
1320
 
                char error_str[100];
1321
 
                strerror_r (errno, error_str, 100);
1322
 
                log_printf (instance->totemudpu_log_level_warning,
1323
 
                        "Could not set non-blocking operation on token socket: %s\n", error_str);
 
1316
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 
1317
                        "Could not set non-blocking operation on token socket");
1324
1318
                return (-1);
1325
1319
        }
1326
1320
 
1327
1321
        /*
1328
 
         * Force reuse
1329
 
         */
1330
 
//       flag = 1;
1331
 
//       if ( setsockopt(instance->token_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof (flag)) < 0) {
1332
 
//              perror("setsockopt reuseaddr");
1333
 
//              return (-1);
1334
 
//      }
1335
 
 
1336
 
        /*
1337
1322
         * Bind to unicast socket used for token send/receives
1338
1323
         * This has the side effect of binding to the correct interface
1339
1324
         */
1340
1325
        totemip_totemip_to_sockaddr_convert(bound_to, instance->totem_interface->ip_port, &sockaddr, &addrlen);
1341
1326
        res = bind (instance->token_socket, (struct sockaddr *)&sockaddr, addrlen);
1342
1327
        if (res == -1) {
1343
 
                perror ("bind token socket failed");
 
1328
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 
1329
                        "bind token socket failed");
1344
1330
                return (-1);
1345
1331
        }
1346
1332
 
1352
1338
        res = setsockopt (instance->token_socket, SOL_SOCKET, SO_RCVBUF,
1353
1339
                &recvbuf_size, optlen);
1354
1340
        if (res == -1) {
1355
 
                char error_str[100];
1356
 
                strerror_r (errno, error_str, 100);
1357
 
                log_printf (instance->totemudpu_log_level_notice,
1358
 
                        "Could not set recvbuf size %s\n", error_str);
 
1341
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_notice,
 
1342
                        "Could not set recvbuf size");
1359
1343
        }
1360
1344
 
1361
1345
        return 0;
1669
1653
        int res;
1670
1654
        unsigned int sendbuf_size;
1671
1655
        unsigned int optlen = sizeof (sendbuf_size);
1672
 
        char error_str[100];
1673
1656
 
1674
1657
        new_member = malloc (sizeof (struct totemudpu_member));
1675
1658
        if (new_member == NULL) {
1680
1663
        memcpy (&new_member->member, member, sizeof (struct totem_ip_address));
1681
1664
        new_member->fd = socket (member->family, SOCK_DGRAM, 0);
1682
1665
        if (new_member->fd == -1) {
1683
 
                strerror_r (errno, error_str, 100);
1684
 
                log_printf (instance->totemudpu_log_level_warning,
1685
 
                        "Could not create socket for new member: %s\n", error_str);
 
1666
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 
1667
                        "Could not create socket for new member");
1686
1668
                return (-1);
1687
1669
        }
1688
1670
        totemip_nosigpipe (new_member->fd);
1689
1671
        res = fcntl (new_member->fd, F_SETFL, O_NONBLOCK);
1690
1672
        if (res == -1) {
1691
 
                strerror_r (errno, error_str, 100);
1692
 
                log_printf (instance->totemudpu_log_level_warning,
1693
 
                        "Could not set non-blocking operation on token socket: %s\n", error_str);
 
1673
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 
1674
                        "Could not set non-blocking operation on token socket");
1694
1675
                return (-1);
1695
1676
        }
1696
1677
 
1702
1683
        res = setsockopt (new_member->fd, SOL_SOCKET, SO_SNDBUF,
1703
1684
                &sendbuf_size, optlen);
1704
1685
        if (res == -1) {
1705
 
                strerror_r (errno, error_str, 100);
1706
 
                log_printf (instance->totemudpu_log_level_notice,
1707
 
                        "Could not set sendbuf size %s\n", error_str);
 
1686
                LOGSYS_PERROR (errno, instance->totemudpu_log_level_notice,
 
1687
                        "Could not set sendbuf size");
1708
1688
        }
1709
1689
        return (0);
1710
1690
}