~ubuntu-branches/ubuntu/oneiric/collectd/oneiric

« back to all changes in this revision

Viewing changes to src/email.c

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-11-18 15:54:20 UTC
  • mfrom: (1.1.5 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20081118155420-sc2mxv2pebafkmon
Tags: 4.4.2-2ubuntu1
* Merge from Debian unstable (LP: #298828). Remaining Ubuntu changes:
* Add ubuntu_in6-glibc28.dpatch patch, fix FTBFS.
* Add ubuntu_hardening.dpatch patch, fix FTBFS.
* Add ubuntu_perl.c.dpatch, fix FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
static void *collect (void *arg)
244
244
{
245
245
        collector_t *this = (collector_t *)arg;
246
 
        pthread_t    self = pthread_self ();
247
246
 
248
247
        while (1) {
249
248
                int loop = 1;
269
268
                 * thread and connection management */
270
269
                this->socket = connection->socket;
271
270
 
272
 
                log_debug ("[thread #%5lu] handling connection on fd #%i",
273
 
                                self, fileno (this->socket));
 
271
                log_debug ("collect: handling connection on fd #%i",
 
272
                                fileno (this->socket));
274
273
 
275
274
                while (loop) {
276
275
                        /* 256 bytes ought to be enough for anybody ;-) */
283
282
 
284
283
                                if (0 != errno) {
285
284
                                        char errbuf[1024];
286
 
                                        log_err ("[thread #%5lu] reading from socket (fd #%i) "
287
 
                                                        "failed: %s", self, fileno (this->socket),
 
285
                                        log_err ("collect: reading from socket (fd #%i) "
 
286
                                                        "failed: %s", fileno (this->socket),
288
287
                                                        sstrerror (errno, errbuf, sizeof (errbuf)));
289
288
                                }
290
289
                                break;
292
291
 
293
292
                        len = strlen (line);
294
293
                        if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
295
 
                                log_warn ("[thread #%5lu] line too long (> %lu characters): "
296
 
                                                "'%s' (truncated)", self, sizeof (line) - 1, line);
 
294
                                log_warn ("collect: line too long (> %zu characters): "
 
295
                                                "'%s' (truncated)", sizeof (line) - 1, line);
297
296
 
298
297
                                while (NULL != fgets (line, sizeof (line), this->socket))
299
298
                                        if (('\n' == line[len - 1]) || ('\r' == line[len - 1]))
303
302
 
304
303
                        line[len - 1] = '\0';
305
304
 
306
 
                        log_debug ("[thread #%5lu] line = '%s'", self, line);
 
305
                        log_debug ("collect: line = '%s'", line);
307
306
 
308
307
                        if (':' != line[1]) {
309
 
                                log_err ("[thread #%5lu] syntax error in line '%s'",
310
 
                                                self, line);
 
308
                                log_err ("collect: syntax error in line '%s'", line);
311
309
                                continue;
312
310
                        }
313
311
 
318
316
                                int  bytes = 0;
319
317
 
320
318
                                if (NULL == tmp) {
321
 
                                        log_err ("[thread #%5lu] syntax error in line '%s'",
322
 
                                                        self, line);
 
319
                                        log_err ("collect: syntax error in line '%s'", line);
323
320
                                        continue;
324
321
                                }
325
322
 
353
350
                                } while (NULL != (type = strtok_r (NULL, ",", &ptr)));
354
351
                        }
355
352
                        else {
356
 
                                log_err ("[thread #%5lu] unknown type '%c'", self, line[0]);
 
353
                                log_err ("collect: unknown type '%c'", line[0]);
357
354
                        }
358
355
                } /* while (loop) */
359
356
 
396
393
 
397
394
        strncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
398
395
        addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
399
 
        unlink (addr.sun_path);
400
396
 
401
397
        errno = 0;
402
398
        if (-1 == bind (connector_socket, (struct sockaddr *)&addr,
657
653
        vl.values = values;
658
654
        vl.values_len = 1;
659
655
        vl.time = time (NULL);
660
 
        strcpy (vl.host, hostname_g);
661
 
        strcpy (vl.plugin, "email");
 
656
        sstrncpy (vl.host, hostname_g, sizeof (vl.host));
 
657
        sstrncpy (vl.plugin, "email", sizeof (vl.plugin));
662
658
        strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
663
659
 
664
660
        plugin_dispatch_values (type, &vl);