components/python/python26/patches/Python26-25-closerange.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Mon, 11 Mar 2013 10:38:09 -0700
branchs11-update
changeset 2520 ceec631e74d1
parent 841 1a62cefa636d
permissions -rw-r--r--
Close of build 10.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
     1
--- Python-2.6.8/Modules/posixmodule.c.orig	2012-05-14 06:31:28.561995103 -0700
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
     2
+++ Python-2.6.8/Modules/posixmodule.c	2012-05-14 06:34:39.031503970 -0700
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
     3
@@ -6378,15 +6378,34 @@
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     4
 "closerange(fd_low, fd_high)\n\n\
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     5
 Closes all file descriptors in [fd_low, fd_high), ignoring errors.");
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     6
 
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     7
+static int
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     8
+close_func(void *lohi, int fd)
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
     9
+{
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    10
+    int lo = ((int *)lohi)[0];
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    11
+    int hi = ((int *)lohi)[1];
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    12
+
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    13
+    if (fd >= hi)
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    14
+        return (1);
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    15
+    else if (fd >= lo)
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    16
+        close(fd);
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    17
+
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    18
+    return (0);
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    19
+}
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    20
+
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    21
 static PyObject *
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    22
 posix_closerange(PyObject *self, PyObject *args)
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    23
 {
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    24
     int fd_from, fd_to, i;
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    25
+    int lohi[2];
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    26
+
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    27
     if (!PyArg_ParseTuple(args, "ii:closerange", &fd_from, &fd_to))
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    28
         return NULL;
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    29
     Py_BEGIN_ALLOW_THREADS
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    30
-    for (i = fd_from; i < fd_to; i++)
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    31
-        close(i);
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    32
+
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    33
+    lohi[0] = fd_from;
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    34
+    lohi[1] = fd_to;
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    35
+    fdwalk(close_func, lohi);
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    36
+
841
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    37
     Py_END_ALLOW_THREADS
1a62cefa636d 7121707 python 2.6.4 should be updated to latest 2.6.X release
Rich Burridge <rich.burridge@oracle.com>
parents: 578
diff changeset
    38
     Py_RETURN_NONE;
578
4f51372decaf 7053223 python needs lint libraries
Danek Duvall <danek.duvall@oracle.com>
parents:
diff changeset
    39
 }