Commit Graph

16 Commits

Author SHA1 Message Date
Ben Noordhuis
038eacfbf4 darwin: speed up uv_set_process_title()
Libuv loaded and unloaded the Core Services and Application Services for
every call to uv_set_process_title().

Change that to load them on the first call to uv_set_process_title() and
delay unloading until libuv is unloaded.

Speeds up process_title_threadsafe by about 10x on my system. It should
fail less often (hopefully not at all) on the CI now.

PR-URL: https://github.com/libuv/libuv/pull/2480
Reviewed-By: Saúl Ibarra Corretgé <s@saghul.net>
2019-10-08 12:49:47 +02:00
Ben Noordhuis
97e86dde84 Revert "darwin: speed up uv_set_process_title()"
This reverts commit 00c6b1649d.

It's been reported (and I can confirm) that this change breaks
`process.title = 'foo'` in Node.js.

Since libuv just calls out to Core Services and Application Services,
and since those frameworks are really just black boxes that you can't
look inside, it's impossible to debug what exactly goes wrong. Revert
it is then.

Fixes: https://github.com/nodejs/node/issues/28945
PR-URL: https://github.com/libuv/libuv/pull/2405
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2019-08-03 21:23:43 +02:00
Ben Noordhuis
8972e65bf5 unix: harden string copying, introduce strscpy()
Replace calls to strcpy() and strncpy() with the newly introduced
uv__strscpy() function that is meticulous about zero-terminating
the destination buffer.

PR-URL: https://github.com/libuv/libuv/pull/2065
Refs: https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-12-04 17:08:09 +01:00
Ben Noordhuis
00c6b1649d darwin: speed up uv_set_process_title()
Libuv loaded and unloaded the Core Services and Application Services for
every call to uv_set_process_title().

Change that to load them on the first call to uv_set_process_title() and
delay unloading until libuv is unloaded.

Speeds up process_title_threadsafe by about 10x on my system.

PR-URL: https://github.com/libuv/libuv/pull/2064
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2018-11-04 18:37:56 +01:00
Mason X
89cbbc895b
include,src: introduce UV__ERR() macro
Using -errno, -E**, and -pthread_function() can be
error prone, and breaks compatibility with some operating
systems that already negate errno's (e.g. Haiku).

This commit adds a UV__ERR() macro that ensures libuv
errors are negative.

Fixes: https://github.com/libuv/help/issues/39
PR-URL: https://github.com/libuv/libuv/pull/1687
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2018-02-08 22:38:02 -05:00
Ben Noordhuis
0b9ee2cf00 unix: fix long line introduced in commit 94e628fa
PR-URL: https://github.com/libuv/libuv/pull/150
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-21 13:04:50 +01:00
Ben Noordhuis
955b1806c7 unix: fix implicit declaration compiler warning
Include <string.h> explicitly to get the definition of strncpy().

Refs https://github.com/libuv/libuv/issues/138.

PR-URL: https://github.com/libuv/libuv/pull/150
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-01-21 13:04:28 +01:00
Recep ASLANTAS
94e628faf1 unix: fix warnings when loading functions with dlsym 2014-09-17 22:47:01 +02:00
Fedor Indutny
ab0225277b Merge branch 'v0.10'
Conflicts:
	src/unix/darwin-proctitle.c
	src/version.c
2013-10-28 20:59:10 +04:00
Fedor Indutny
08e0e63f3a darwin: avoid calling GetCurrentProcess
Use some black-magic from Apple to change process name without getting
a "Not responding" tag from Activity Manager.

fix #966
2013-10-28 20:51:50 +04:00
Ben Noordhuis
d48168afd0 darwin: remove CoreFoundation dependency
Load the required symbols at run-time rather than linking against the
CoreFoundation (and CoreServices and ApplicationServices) frameworks
at build time.

Should make integration easier for people that bundle libuv with their
own projects because they no longer have to replicate magic -framework
incantations in their top-level build system.
2013-08-27 23:58:21 +02:00
Ben Noordhuis
b03192ed6f darwin: fix ios build error
Include <errno.h> and <stdlib.h>.  They're being pulled in implicitly
on OS X but apparently that's not the case with iOS builds.

Build breakage introduced in 5ff6f85 by yours truly. Mea culpa.

Fixes #885 and #891.
2013-08-19 13:26:57 +02:00
Ben Noordhuis
5ff6f85f58 darwin: call pthread_setname_np() if available
When setting the process title, also call pthread_setname_np() when
supported (OS X >= 10.6 and iOS >= 3.2.)
2013-08-15 21:52:26 +02:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Ben Noordhuis
f22163c233 darwin: fix ios build, don't require ApplicationServices 2013-05-13 20:16:20 +02:00
Ben Noordhuis
9b801d551b darwin: rename darwin-getproctitle.m
Rename it to darwin-getproctitle.c, it doesn't need an Objective-C
compiler. Fix up -Wpedantic warnings about void to function pointer
casts and include <ApplicationServices/ApplicationServices.h> to get
the GetCurrentProcess() function prototype.
2013-05-02 14:10:12 +02:00