Author: rfm
Date: Fri May 13 15:19:22 2016
New Revision: 39753
URL: http://svn.gna.org/viewcvs/gnustep?rev=39753&view=rev
Log:
fgix for problem spotted by Wolfgang
Modified:
libs/base/trunk/ChangeLog
libs/base/trunk/Source/NSThread.m
Modified: libs/base/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39753&r1=39752&r2=39753&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog (original)
+++ libs/base/trunk/ChangeLog Fri May 13 15:19:22 2016
@@ -2,6 +2,9 @@
* Source/Additions/GSMime.m:
Fix bug encoding very long headers with no whitespace to fold on.
+ * Source/NSThread.m:
+ Avoid use of autorelease pool when setting the name of the thread
+ (fix pointless warnings logs spotted by Wolfgang).
2016-05-06 18:03-EDT Gregory John Casamento <[email protected]>
Modified: libs/base/trunk/Source/NSThread.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSThread.m?rev=39753&r1=39752&r2=39753&view=diff
==============================================================================
--- libs/base/trunk/Source/NSThread.m (original)
+++ libs/base/trunk/Source/NSThread.m Fri May 13 15:19:22 2016
@@ -1056,25 +1056,65 @@
- (void) _setName: (NSString *)aName
{
- int result = -1;
-
- while (result != 0 && [aName length] > 0)
- {
- result =
- PTHREAD_SETNAME([aName cStringUsingEncoding: NSUTF8StringEncoding]);
- if (result != 0)
+ if ([aName isKindOfClass: [NSString class]])
+ {
+ int i;
+ char buf[200];
+
+ if (YES == [aName getCString: buf
+ maxLength: sizeof(buf)
+ encoding: NSUTF8StringEncoding])
{
+ i = strlen(buf);
+ }
+ else
+ {
+ /* Too much for buffer ... truncate on a character boundary.
+ */
+ i = sizeof(buf) - 1;
+ if (buf[i] & 0x80)
+ {
+ while (i > 0 && (buf[i] & 0x80))
+ {
+ buf[i--] = '\0';
+ }
+ }
+ else
+ {
+ buf[i--] = '\0';
+ }
+ }
+ while (i > 0)
+ {
+ if (PTHREAD_SETNAME(buf) == 0)
+ {
+ break; // Success
+ }
+
if (ERANGE == errno)
{
/* Name must be too long ... gnu/linux uses 15 characters
*/
- if ([aName length] > 15)
+ if (i > 15)
{
- aName = [aName substringToIndex: 15];
+ i = 15;
}
else
{
- aName = [aName substringToIndex: [aName length] - 1];
+ i--;
+ }
+ /* too long a name ... truncate on a character boundary.
+ */
+ if (buf[i] & 0x80)
+ {
+ while (i > 0 && (buf[i] & 0x80))
+ {
+ buf[i--] = '\0';
+ }
+ }
+ else
+ {
+ buf[i--] = '\0';
}
}
else
@@ -1112,13 +1152,12 @@
/**
* Trampoline function called to launch the thread
*/
-static void *nsthreadLauncher(void *thread)
-{
- NSThread *t = (NSThread*)thread;
- setThreadForCurrentThread(t);
-#if __OBJC_GC__
- objc_registerThreadWithCollector();
-#endif
+static void *
+nsthreadLauncher(void *thread)
+{
+ NSThread *t = (NSThread*)thread;
+
+ setThreadForCurrentThread(t);
/*
* Let observers know a new thread is starting.
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs