Changeset b9dd49a for lib/ior-thread.c


Ignore:
Timestamp:
03/12/10 13:26:57 (12 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.

File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.