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
55a8338d
Kaydet (Commit)
55a8338d
authored
Eyl 20, 2000
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
On Unix, use O_EXCL when creating the .pyc/.pyo files, to avoid a race condition
üst
6c0f33f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
import.c
Python/import.c
+31
-1
No files found.
Python/import.c
Dosyayı görüntüle @
55a8338d
...
@@ -28,12 +28,17 @@
...
@@ -28,12 +28,17 @@
#ifndef DONT_HAVE_SYS_TYPES_H
#ifndef DONT_HAVE_SYS_TYPES_H
#include <sys/types.h>
#include <sys/types.h>
#endif
#endif
#ifndef DONT_HAVE_SYS_STAT_H
#ifndef DONT_HAVE_SYS_STAT_H
#include <sys/stat.h>
#include <sys/stat.h>
#elif defined(HAVE_STAT_H)
#elif defined(HAVE_STAT_H)
#include <stat.h>
#include <stat.h>
#endif
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#if defined(PYCC_VACPP)
#if defined(PYCC_VACPP)
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG)
...
@@ -627,6 +632,31 @@ parse_source_module(char *pathname, FILE *fp)
...
@@ -627,6 +632,31 @@ parse_source_module(char *pathname, FILE *fp)
}
}
/* Helper to open a bytecode file for writing in exclusive mode */
static
FILE
*
open_exclusive
(
char
*
filename
)
{
#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC)
/* Use O_EXCL to avoid a race condition when another process tries to
write the same file. When that happens, our open() call fails,
which is just fine (since it's only a cache).
XXX If the file exists and is writable but the directory is not
writable, the file will never be written. Oh well.
*/
int
fd
;
(
void
)
unlink
(
filename
);
fd
=
open
(
filename
,
O_EXCL
|
O_CREAT
|
O_WRONLY
|
O_TRUNC
,
0666
);
if
(
fd
<
0
)
return
NULL
;
return
fdopen
(
fd
,
"wb"
);
#else
/* Best we can do -- on Windows this can't happen anyway */
return
fopen
(
filename
,
"wb"
);
#endif
}
/* Write a compiled module to a file, placing the time of last
/* Write a compiled module to a file, placing the time of last
modification of its source into the header.
modification of its source into the header.
Errors are ignored, if a write error occurs an attempt is made to
Errors are ignored, if a write error occurs an attempt is made to
...
@@ -637,7 +667,7 @@ write_compiled_module(PyCodeObject *co, char *cpathname, long mtime)
...
@@ -637,7 +667,7 @@ write_compiled_module(PyCodeObject *co, char *cpathname, long mtime)
{
{
FILE
*
fp
;
FILE
*
fp
;
fp
=
fopen
(
cpathname
,
"wb"
);
fp
=
open_exclusive
(
cpathname
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
if
(
Py_VerboseFlag
)
if
(
Py_VerboseFlag
)
PySys_WriteStderr
(
PySys_WriteStderr
(
...
...
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