* commit 'ea46b36f894477755487d8caec15a8f35f81ac2c': Fix POSIX timer thread naming.
This commit is contained in:
		@@ -174,10 +174,10 @@ int timer_create(clockid_t clock_id, sigevent* evp, timer_t* timer_id) {
 | 
				
			|||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Give the thread a meaningful name.
 | 
					  // Give the thread a specific meaningful name.
 | 
				
			||||||
  // It can't do this itself because the kernel timer isn't created until after it's running.
 | 
					  // It can't do this itself because the kernel timer isn't created until after it's running.
 | 
				
			||||||
  char name[32];
 | 
					  char name[16]; // 16 is the kernel-imposed limit.
 | 
				
			||||||
  snprintf(name, sizeof(name), "POSIX interval timer %d", to_kernel_timer_id(timer));
 | 
					  snprintf(name, sizeof(name), "POSIX timer %d", to_kernel_timer_id(timer));
 | 
				
			||||||
  pthread_setname_np(timer->callback_thread, name);
 | 
					  pthread_setname_np(timer->callback_thread, name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  *timer_id = timer;
 | 
					  *timer_id = timer;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -404,7 +404,9 @@ TEST(pthread, pthread_sigmask) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(pthread, pthread_setname_np__too_long) {
 | 
					TEST(pthread, pthread_setname_np__too_long) {
 | 
				
			||||||
  ASSERT_EQ(ERANGE, pthread_setname_np(pthread_self(), "this name is far too long for linux"));
 | 
					  // The limit is 15 characters --- the kernel's buffer is 16, but includes a NUL.
 | 
				
			||||||
 | 
					  ASSERT_EQ(0, pthread_setname_np(pthread_self(), "123456789012345"));
 | 
				
			||||||
 | 
					  ASSERT_EQ(ERANGE, pthread_setname_np(pthread_self(), "1234567890123456"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(pthread, pthread_setname_np__self) {
 | 
					TEST(pthread, pthread_setname_np__self) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user