This file is indexed.

/var/lib/pcp/testsuite/src/clienttimeout.c is in pcp-testsuite 4.0.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Exercise client-side libpcp timeout settings.
 *
 * Copyright (c) 2015 Red Hat.
 */

#include <pcp/pmapi.h>
#include "libpcp.h"

int
main(int argc, char *argv[])
{
    int		ctx;
    int		sts;
    int		c;
    int		errflag = 0;
    int		Pflag = 0, pflag = 0, Cflag = 0, sflag = 0, Sflag = 0;
    char	*end_ptr;
    double	req_timeout = 42.0;
    double	conn_timeout = 120.0;
    static char	*usage = "[-CpPsS] [-c sec] [-r sec] [-D debugopts]";

    pmSetProgname(argv[0]);

    while ((c = getopt(argc, argv, "c:CpPsSr:D:")) != EOF) {
	switch (c) {

	case 'C':
	    Cflag = 1;
	    break;

	case 'p':
	    pflag = 1;
	    break;

	case 'P':
	    Pflag = 1;
	    break;

	case 's':
	    sflag = 1;
	    break;

	case 'S':
	    Sflag = 1;
	    break;

	case 'D':	/* debug options */
	    sts = pmSetDebug(optarg);
	    if (sts < 0) {
		fprintf(stderr, "%s: unrecognized debug options specification (%s)\n",
		    pmGetProgname(), optarg);
		errflag++;
	    }
	    break;

	case 'c':
	    conn_timeout = strtod(optarg, &end_ptr);
	    if (*end_ptr != '\0') {
		fprintf(stderr, "%s: invalid timeout specification (%s)\n",
                              pmGetProgname(), optarg);
		errflag++;
	    }
	    break;

	case 'r':
	    req_timeout = strtod(optarg, &end_ptr);
	    if (*end_ptr != '\0') {
		fprintf(stderr, "%s: invalid timeout specification (%s)\n",
                              pmGetProgname(), optarg);
		errflag++;
	    }
	    break;

	case '?':
	default:
	    errflag++;
	    break;
	}
    }

    if (errflag) {
	printf("Usage: %s %s\n", pmGetProgname(), usage);
	exit(1);
    }

    if (sflag) {
	if ((sts = __pmSetConnectTimeout(conn_timeout)) < 0) {
	    fprintf(stderr, "__pmSetConnectTimeout(%.2f): %s\n",
		    conn_timeout, pmErrStr(sts));
	}
	if ((sts = __pmSetRequestTimeout(req_timeout)) < 0) {
	    fprintf(stderr, "__pmSetRequestTimeout(%.2f): %s\n",
		    req_timeout, pmErrStr(sts));
	}
    }

    if (pflag) {
	printf("Connect timeout pre-ctx: %.3f\n", __pmConnectTimeout());
	printf("Request timeout pre-ctx: %.3f\n", __pmRequestTimeout());
    }

    if ((ctx = pmNewContext(PM_CONTEXT_HOST, "localhost")) < 0) {
	fprintf(stderr, "pmNewContext(..., \"localhost\"): %s\n",
		pmErrStr(ctx));
	exit(1);
    }

    if (Cflag) {
	printf("Connect timeout post-ctx: %.3f\n", __pmConnectTimeout());
	printf("Request timeout post-ctx: %.3f\n", __pmRequestTimeout());
    }

    if (Sflag) {
	if ((sts = __pmSetConnectTimeout(conn_timeout)) < 0) {
	    fprintf(stderr, "__pmSetConnectTimeout(%.2f): %s\n",
		    conn_timeout, pmErrStr(sts));
	}
	if ((sts = __pmSetRequestTimeout(req_timeout)) < 0) {
	    fprintf(stderr, "__pmSetRequestTimeout(%.2f): %s\n",
		    req_timeout, pmErrStr(sts));
	}
    }

    if (Pflag) {
	printf("Connect timeout post-set: %.3f\n", __pmConnectTimeout());
	printf("Request timeout post-set: %.3f\n", __pmRequestTimeout());
    }

    pmDestroyContext(ctx);

    exit(0);
}