Changeset 4589
- Timestamp:
- 02/26/10 10:37:57 (5 months ago)
- Location:
- trunk/varnish-cache/bin/varnishadm
- Files:
-
- 2 modified
-
varnishadm.1 (modified) (2 diffs)
-
varnishadm.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/varnish-cache/bin/varnishadm/varnishadm.1
r4025 r4589 37 37 .Sh SYNOPSIS 38 38 .Nm 39 .Op Fl t Ar timeout 39 40 .Fl T Ar address Ns : Ns Ar port 40 41 .Cm command … … 49 50 The following options are available: 50 51 .Bl -tag -width Fl 52 .It Fl t Ar timeout 53 Wait no longer than this many seconds for an operation to finish. 51 54 .It Fl T Ar address Ns : Ns Ar port 52 55 Connect to the management interface at the specified address and port. -
trunk/varnish-cache/bin/varnishadm/varnishadm.c
r4587 r4589 43 43 #include "vss.h" 44 44 45 static double timeout = 5; 46 45 47 /* 46 48 * This function establishes a connection to the specified ip and port and … … 52 54 telnet_mgt(const char *T_arg, int argc, char *argv[]) 53 55 { 54 struct vss_addr **ta; 55 char *addr, *port; 56 int i, n; 56 int i; 57 57 int sock; 58 58 unsigned status; 59 59 char *answer = NULL; 60 60 61 XXXAZ(VSS_parse(T_arg, &addr, &port)); 62 XXXAN(n = VSS_resolve(addr, port, &ta)); 63 free(addr); 64 free(port); 65 if (n == 0) { 66 fprintf(stderr, "Could not resolve '%s'\n", T_arg); 67 exit(2); 61 sock = VSS_open(T_arg, timeout); 62 if (sock < 0) { 63 fprintf(stderr, "Connection failed\n"); 64 exit(1); 68 65 } 69 66 70 sock = VSS_connect(ta[0], 0); 71 72 for (i = 0; i < n; ++i) { 73 free(ta[i]); 74 ta[i] = NULL; 75 } 76 free(ta); 77 78 cli_readres(sock, &status, &answer, 2000); 67 cli_readres(sock, &status, &answer, timeout); 79 68 if (status == CLIS_AUTH) { 80 69 fprintf(stderr, "Authentication required\n"); … … 87 76 88 77 write(sock, "ping\n", 5); 89 cli_readres(sock, &status, &answer, 2000);78 cli_readres(sock, &status, &answer, timeout); 90 79 if (status != CLIS_OK || strstr(answer, "PONG") == NULL) { 91 80 fprintf(stderr, "No pong received from server\n"); … … 118 107 { 119 108 fprintf(stderr, 120 "usage: varnishadm -T [address]:port command [...]\n");109 "usage: varnishadm [-t timeout] -T [address]:port command [...]\n"); 121 110 exit(1); 122 111 } … … 128 117 int opt; 129 118 130 while ((opt = getopt(argc, argv, "T: ")) != -1) {119 while ((opt = getopt(argc, argv, "T:t:")) != -1) { 131 120 switch (opt) { 132 121 case 'T': 133 122 T_arg = optarg; 123 break; 124 case 't': 125 timeout = strtod(optarg, NULL); 134 126 break; 135 127 default:
