Changeset b9dd49a


Ignore:
Timestamp:
03/12/10 13:26:57 (11 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
441f34d
Parents:
66649b4
Message:

Name threads on linux so we can tell them apart.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/ior-thread.c

    r22a9ccc rb9dd49a  
    3434
    3535#include "wandio.h"
     36#include "config.h"
    3637#include <sys/types.h>
    3738#include <sys/stat.h>
     
    4243#include <stdbool.h>
    4344#include <errno.h>
     45#ifdef HAVE_SYS_PRCTL_H
     46#include <sys/prctl.h>
     47#endif
    4448
    4549/* Libtrace IO module implementing a threaded reader.
     
    97101        int buffer=0;
    98102        bool running = true;
     103        char namebuf[17];
     104
     105#ifdef PR_SET_NAME
     106        if (prctl(PR_GET_NAME, namebuf, 0,0,0) == 0) {
     107                namebuf[16] = '\0'; /* Make sure it's NUL terminated */
     108                /* If the filename is too long, overwrite the last few bytes */
     109                if (strlen(namebuf)>9) {
     110                        strcpy(namebuf+10,"[ior]");
     111                }
     112                else {
     113                        strncat(namebuf," [ior]",16);
     114                }
     115                prctl(PR_SET_NAME, namebuf, 0,0,0);
     116        }
     117#endif
    99118
    100119        pthread_mutex_lock(&DATA(state)->mutex);
  • lib/iow-thread.c

    r22a9ccc rb9dd49a  
    3333
    3434#include "wandio.h"
     35#include "config.h"
    3536#include <sys/types.h>
    3637#include <sys/stat.h>
     
    4041#include <string.h>
    4142#include <stdbool.h>
     43#ifdef HAVE_SYS_PRCTL_H
     44#include <sys/prctl.h>
     45#endif
    4246
    4347/* Libtrace IO module implementing a threaded writer.
     
    9599        int buffer=0;
    96100        bool running = true;
     101        char namebuf[17];
    97102        iow_t *state = (iow_t *) userdata;
     103
     104#ifdef PR_SET_NAME
     105        if (prctl(PR_GET_NAME, namebuf, 0,0,0) == 0) {
     106                namebuf[16] = '\0'; /* Make sure it's NUL terminated */
     107                /* If the filename is too long, overwrite the last few bytes */
     108                if (strlen(namebuf)>9) {
     109                        strcpy(namebuf+10,"[iow]");
     110                }
     111                else {
     112                        strncat(namebuf," [iow]",16);
     113                }
     114                prctl(PR_SET_NAME, namebuf, 0,0,0);
     115        }
     116#endif
    98117
    99118        pthread_mutex_lock(&DATA(state)->mutex);
Note: See TracChangeset for help on using the changeset viewer.