[gnome-builder/wip/chergert/debugger] runner: improve max_fd discovery
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/debugger] runner: improve max_fd discovery
- Date: Fri, 24 Mar 2017 11:38:27 +0000 (UTC)
commit db832f8340222188821299a7164e623eb2de397a
Author: Christian Hergert <chergert redhat com>
Date: Fri Mar 24 04:36:43 2017 -0700
runner: improve max_fd discovery
We should be more vigilant in getting a proper FD number to map in.
libide/runner/ide-runner.c | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/libide/runner/ide-runner.c b/libide/runner/ide-runner.c
index a89a642..152cc39 100644
--- a/libide/runner/ide-runner.c
+++ b/libide/runner/ide-runner.c
@@ -1145,10 +1145,17 @@ ide_runner_take_fd (IdeRunner *self,
*/
if (dest_fd < 0)
{
- if (priv->fd_mapping->len == 0)
- dest_fd = 3;
- else
- dest_fd = g_array_index (priv->fd_mapping, FdMapping, priv->fd_mapping->len - 1).dest_fd + 1;
+ gint max_fd = 2;
+
+ for (guint i = 0; i < priv->fd_mapping->len; i++)
+ {
+ FdMapping *entry = &g_array_index (priv->fd_mapping, FdMapping, i);
+
+ if (entry->dest_fd > max_fd)
+ max_fd = entry->dest_fd;
+ }
+
+ dest_fd = max_fd + 1;
}
map.source_fd = source_fd;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]