I've posted each of these patches previously, but haven't heard a certain word as to their acceptance or rejection. Can someone please consider them?
1) Add a nodelay() function to Stdio.Files. There was some discussion as to whether or not this should be done in a more general way, but the discussion flagged and no conclusion was reached. 2) Represent a GTK G_TYPE_POINTER argument as an integer, rather than as an object. Every example I can find of a G_TYPE_POINTER coming back results in a segfault of Pike, which suggests that it's really not an object. I haven't found any instances where it really is meant to be an object, but that doesn't mean there aren't any. Does anyone know for sure? In any case, returning integers is safe for cases like the Notebook switch-page signal. 3) Ensure that something, at least, is pushed for every argument to a GTK signal callback function. Currently, unrecognized types can be simply skipped, resulting in stack mangling. My patch pushes the name of the type, thus preventing segfaults. The two GTK patches apply cleanly to 7.8 as well as 8.0, and can be considered bugfixes. The nodelay() function is definitely a feature addition, and is also not as important. Would love to see the GTK fixes arrive in time to go into the next published builds. Thanks! ChrisA
From a063c2b2c8da29b2543aba4e5a34dc3c7ae12ae3 Mon Sep 17 00:00:00 2001 From: Chris Angelico <ros...@gmail.com> Date: Fri, 6 Dec 2013 01:02:58 +1100 Subject: [PATCH 1/3] Add nodelay() function to Stdio.File objects to control Nagling --- src/modules/_Stdio/file.c | 52 +++++++++++++++++++++++++++++++++++ src/modules/_Stdio/file_functions.h | 6 ++++ 2 files changed, 58 insertions(+) diff --git a/src/modules/_Stdio/file.c b/src/modules/_Stdio/file.c index 40378e8..81525dc 100644 --- a/src/modules/_Stdio/file.c +++ b/src/modules/_Stdio/file.c @@ -121,6 +121,10 @@ #include <net/netdb.h> #endif /* HAVE_NET_NETDB_H */ +#ifdef HAVE_NETINET_TCP_H +#include <netinet/tcp.h> +#endif + #include "dmalloc.h" @@ -2395,6 +2399,54 @@ static void file_linger(INT32 args) } #endif +#ifdef TCP_NODELAY +/*! @decl int(0..1) nodelay(int(0..1)|void state) + *! + *! Control Nagle's Algorithm (RFC 896) + *! + *! @param state + *! @int + *! @value 0 + *! Return to the normal state of using Nagle's Algorithm + *! @value 1 + *! (default) Disable Nagling - small writes will not be queued. + *! @endint + *! + *! @returns + *! Returns @expr{1@} on success, and @expr{0@} (zero) on failure. + *! + *! @note + *! This operation is only valid on sockets. + */ +static void file_nodelay(INT32 args) +{ + int fd = FD; + int state = 1; + + if(fd < 0) + Pike_error("File not open.\n"); + + get_all_args("Stdio.File->nodelay", args, ".%d", &state); + + if (state && state != 1) { + SIMPLE_BAD_ARG_ERROR("Stdio.File->nodelay()", 1, "int(0..1)"); + } + + errno = 0; + while ((fd_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, + &state, sizeof(state)) < 0) && + (errno == EINTR)) { + errno = 0; + } + if (errno) { + ERRNO = errno; + push_int(0); + } else { + push_int(1); + } +} +#endif + static int do_close(int flags) { struct my_file *f = THIS; diff --git a/src/modules/_Stdio/file_functions.h b/src/modules/_Stdio/file_functions.h index 0898655..3ca3f60 100644 --- a/src/modules/_Stdio/file_functions.h +++ b/src/modules/_Stdio/file_functions.h @@ -44,6 +44,12 @@ FILE_FUNC("linger", file_linger, tFunc(tOr3(tInt_10, tWord, tVoid), tInt01)) #endif +#ifdef TCP_NODELAY +/* function(int(0..1)|void:int(0..1)) */ +FILE_FUNC("nodelay", file_nodelay, + tFunc(tOr(tInt01, tVoid), tInt01)) +#endif + #ifdef HAVE_FSYNC /* function(:int) */ FILE_FUNC("sync", file_sync, tFunc(tNone,tInt)) -- 1.7.10.4
From 23804eff162b8f104cef3abe2f516556484c8d3c Mon Sep 17 00:00:00 2001 From: Chris Angelico <ros...@gmail.com> Date: Sat, 15 Mar 2014 11:11:05 +1100 Subject: [PATCH 2/3] Represent G_TYPE_POINTER as an integer to prevent segfaults --- src/post_modules/GTK2/source/support.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/post_modules/GTK2/source/support.c b/src/post_modules/GTK2/source/support.c index 072eb7c..dfa5eb3 100644 --- a/src/post_modules/GTK2/source/support.c +++ b/src/post_modules/GTK2/source/support.c @@ -599,9 +599,7 @@ static int pgtk2_push_object_param(const GValue *a) { } static int pgtk2_push_pike_object_param(const GValue *a) { - struct object *o=g_value_get_pointer(a); - if (o) - ref_push_object(o); + push_int64((LONGEST)g_value_get_pointer(a)); return PUSHED_VALUE; } -- 1.7.10.4
From 3c0133375b65afa188fa1b119f234fc172d54743 Mon Sep 17 00:00:00 2001 From: Chris Angelico <ros...@gmail.com> Date: Sat, 15 Mar 2014 23:08:34 +1100 Subject: [PATCH 3/3] Ensure something's pushed for every argument to a GTK2 signal callback --- src/post_modules/GTK2/source/support.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/post_modules/GTK2/source/support.c b/src/post_modules/GTK2/source/support.c index dfa5eb3..74466e8 100644 --- a/src/post_modules/GTK2/source/support.c +++ b/src/post_modules/GTK2/source/support.c @@ -589,6 +589,9 @@ static int pgtk2_push_object_param(const GValue *a) { push_gdkobject(gp,rectangle,0); } else if (G_VALUE_HOLDS(a,g_type_from_name("GdkRegion"))) { push_gdkobject(gp,region,0); + } else { + /* Don't know how to push this sort of object, so push its name */ + PGTK_PUSH_GCHAR(G_VALUE_TYPE_NAME(a)); } } else { obj=g_value_get_object(a); -- 1.7.10.4