Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b1973c25
Kaydet (Commit)
b1973c25
authored
Agu 20, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #8865: Concurrent invocation of select.poll.poll() now raises a
RuntimeError exception. Patch by Christian Schubert.
üst
ec67d187
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
2 deletions
+57
-2
test_poll.py
Lib/test/test_poll.py
+40
-2
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
selectmodule.c
Modules/selectmodule.c
+13
-0
No files found.
Lib/test/test_poll.py
Dosyayı görüntüle @
b1973c25
# Test case for the os.poll() function
# Test case for the os.poll() function
import
os
,
select
,
random
,
unittest
import
os
import
random
import
select
import
_testcapi
import
_testcapi
from
test.support
import
TESTFN
,
run_unittest
try
:
import
threading
except
ImportError
:
threading
=
None
import
time
import
unittest
from
test.support
import
TESTFN
,
run_unittest
,
reap_threads
try
:
try
:
select
.
poll
select
.
poll
...
@@ -160,6 +168,36 @@ class PollTests(unittest.TestCase):
...
@@ -160,6 +168,36 @@ class PollTests(unittest.TestCase):
self
.
assertRaises
(
OverflowError
,
pollster
.
poll
,
_testcapi
.
INT_MAX
+
1
)
self
.
assertRaises
(
OverflowError
,
pollster
.
poll
,
_testcapi
.
INT_MAX
+
1
)
self
.
assertRaises
(
OverflowError
,
pollster
.
poll
,
_testcapi
.
UINT_MAX
+
1
)
self
.
assertRaises
(
OverflowError
,
pollster
.
poll
,
_testcapi
.
UINT_MAX
+
1
)
@unittest.skipUnless
(
threading
,
'Threading required for this test.'
)
@reap_threads
def
test_threaded_poll
(
self
):
r
,
w
=
os
.
pipe
()
self
.
addCleanup
(
os
.
close
,
r
)
self
.
addCleanup
(
os
.
close
,
w
)
rfds
=
[]
for
i
in
range
(
10
):
fd
=
os
.
dup
(
r
)
self
.
addCleanup
(
os
.
close
,
fd
)
rfds
.
append
(
fd
)
pollster
=
select
.
poll
()
for
fd
in
rfds
:
pollster
.
register
(
fd
,
select
.
POLLIN
)
t
=
threading
.
Thread
(
target
=
pollster
.
poll
)
t
.
start
()
try
:
time
.
sleep
(
0.5
)
# trigger ufds array reallocation
for
fd
in
rfds
:
pollster
.
unregister
(
fd
)
pollster
.
register
(
w
,
select
.
POLLOUT
)
self
.
assertRaises
(
RuntimeError
,
pollster
.
poll
)
finally
:
# and make the call to poll() from the thread return
os
.
write
(
w
,
b
'spam'
)
t
.
join
()
def
test_main
():
def
test_main
():
run_unittest
(
PollTests
)
run_unittest
(
PollTests
)
...
...
Misc/ACKS
Dosyayı görüntüle @
b1973c25
...
@@ -1097,6 +1097,7 @@ Arvin Schnell
...
@@ -1097,6 +1097,7 @@ Arvin Schnell
Scott Schram
Scott Schram
Robin Schreiber
Robin Schreiber
Chad J. Schroeder
Chad J. Schroeder
Christian Schubert
Sam Schulenburg
Sam Schulenburg
Stefan Schwarzer
Stefan Schwarzer
Dietmar Schwertberger
Dietmar Schwertberger
...
...
Misc/NEWS
Dosyayı görüntüle @
b1973c25
...
@@ -66,6 +66,9 @@ Core and Builtins
...
@@ -66,6 +66,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #8865: Concurrent invocation of select.poll.poll() now raises a
RuntimeError exception. Patch by Christian Schubert.
- Issue #13461: Fix a crash in the TextIOWrapper.tell method on 64-bit
- Issue #13461: Fix a crash in the TextIOWrapper.tell method on 64-bit
platforms. Patch by Yogesh Chaudhari.
platforms. Patch by Yogesh Chaudhari.
...
...
Modules/selectmodule.c
Dosyayı görüntüle @
b1973c25
...
@@ -332,6 +332,7 @@ typedef struct {
...
@@ -332,6 +332,7 @@ typedef struct {
int
ufd_uptodate
;
int
ufd_uptodate
;
int
ufd_len
;
int
ufd_len
;
struct
pollfd
*
ufds
;
struct
pollfd
*
ufds
;
int
poll_running
;
}
pollObject
;
}
pollObject
;
static
PyTypeObject
poll_Type
;
static
PyTypeObject
poll_Type
;
...
@@ -528,16 +529,27 @@ poll_poll(pollObject *self, PyObject *args)
...
@@ -528,16 +529,27 @@ poll_poll(pollObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
/* Avoid concurrent poll() invocation, issue 8865 */
if
(
self
->
poll_running
)
{
PyErr_SetString
(
PyExc_RuntimeError
,
"concurrent poll() invocation"
);
return
NULL
;
}
/* Ensure the ufd array is up to date */
/* Ensure the ufd array is up to date */
if
(
!
self
->
ufd_uptodate
)
if
(
!
self
->
ufd_uptodate
)
if
(
update_ufd_array
(
self
)
==
0
)
if
(
update_ufd_array
(
self
)
==
0
)
return
NULL
;
return
NULL
;
self
->
poll_running
=
1
;
/* call poll() */
/* call poll() */
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
poll_result
=
poll
(
self
->
ufds
,
self
->
ufd_len
,
timeout
);
poll_result
=
poll
(
self
->
ufds
,
self
->
ufd_len
,
timeout
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
self
->
poll_running
=
0
;
if
(
poll_result
<
0
)
{
if
(
poll_result
<
0
)
{
PyErr_SetFromErrno
(
PyExc_OSError
);
PyErr_SetFromErrno
(
PyExc_OSError
);
return
NULL
;
return
NULL
;
...
@@ -614,6 +626,7 @@ newPollObject(void)
...
@@ -614,6 +626,7 @@ newPollObject(void)
array pointed to by ufds matches the contents of the dictionary. */
array pointed to by ufds matches the contents of the dictionary. */
self
->
ufd_uptodate
=
0
;
self
->
ufd_uptodate
=
0
;
self
->
ufds
=
NULL
;
self
->
ufds
=
NULL
;
self
->
poll_running
=
0
;
self
->
dict
=
PyDict_New
();
self
->
dict
=
PyDict_New
();
if
(
self
->
dict
==
NULL
)
{
if
(
self
->
dict
==
NULL
)
{
Py_DECREF
(
self
);
Py_DECREF
(
self
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment