Revisions

gist: 139760 Download_button fork
public
Public Clone URL: git://gist.github.com/139760.git
Embed All Files: show embed
log.txt #
1
2
3
4
5
6
7
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said ttopensock : 99 : Cannot assign requested address
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said tcrdbopen : 99 : Cannot assign requested address
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said (/3208364753189455067) Failed to open primary, attempting backup : 3 : connection refused
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said (/3208364753189455067) Connecting to backup at port 10101
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said ttopensock : 99 : Cannot assign requested address
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said (/3208364753189455067) Failed to open backup : 3 : connection refused
Jul 2 22:08:31 varnish-test varnishd[26408]: Child (26409) said (/3208364753189455067) Unable to connect to keyserver
message_archive_backend.c #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
long message_archive_backend( const char *req_url, int num_restarts )
{
    TCRDB *conn = tcrdbnew();
    long port = 0;
    bool is_open = false;
    char* backend_config = NULL;
 
    /* fprintf( stderr, "Connecting to primary %s at port %d\n", keyspace_server_primary_config.host, keyspace_server_primary_config.port ); */
    is_open = tcrdbopen( conn, keyspace_server_primary_config.host, keyspace_server_primary_config.port );
    if ( !is_open ) {
        int ecode = tcrdbecode( conn );
        fprintf( stderr, "tcrdbopen : %d : %s\n", errno, strerror( errno ));
        fprintf( stderr, "(%s) Failed to open primary, attempting backup : %d : %s\n", req_url, ecode, tcrdberrmsg( ecode ));
        fprintf( stderr, "(%s) Connecting to backup %s at port %d\n", req_url, keyspace_server_backup_config.host, keyspace_server_backup_config.port );
        is_open = tcrdbopen( conn, keyspace_server_backup_config.host, keyspace_server_backup_config.port );
        if ( !is_open) {
            int ecode = tcrdbecode( conn );
            fprintf( stderr, "(%s) Failed to open backup : %d : %s\n", req_url, ecode, tcrdberrmsg( ecode ));
            return -503;
        }
    }
 
    /* fprintf( stderr, "Calling backend_for '%s'\n", req_url); */
    backend_config = tcrdbext2( conn, "backend_for", RDBXOLCKGLB, req_url,
                               ( (0 == num_restarts) ? "primary" : "backup" ) );
 
    /* if there is a backend config, get the port number */
    if ( NULL != backend_config ) {
        /* fprintf( stderr, "Received a response %s\n", backend_config); */
        char *colon = strrchr( backend_config, ':' );
 
        /* colon found attempt to convert to a long */
        if ( NULL != colon ) {
            colon++; /* move past the colon itself */
            port = strtol( colon, NULL, 10 );
 
            /* unable to convert to a good number */
            if ( 0 == port || LONG_MIN == port || LONG_MAX == port ) {
                port = -1;
            }
        } else {
          /* no port number found */
            port = 0;
        }
    } else {
        port = -404;
    }
 
    if ( !tcrdbclose( conn ) ) {
      fprintf( stderr, "(%s) Unable to close tcrdb connection\n", req_url);
    }
    tcrdbdel( conn );
    free( backend_config );
 
    return port;
}