Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

git-svn-id: svn://cherokee-project.com/cherokee/trunk@862 5dc97367-97…

…f1-0310-9951-d761b3857238
  • Loading branch information...
commit 7db7dc32f43ec6ccd89ba3082f1832d1d7acc4f9 1 parent 16f12b3
@alobbs alobbs authored
View
14 ChangeLog
@@ -1,5 +1,15 @@
2007-07-26 Alvaro Lopez Ortega <alvaro@alobbs.com>
+ * cherokee/util.c (cherokee_mkstemp): Added new function. It wraps
+ mkstemp() and cherokee_win32_mkstemp().
+
+2007-07-23 Ross Smith II <cherokeespam at netebb.com>
+
+ * cherokee/post.c, cherokee/win32_misc.c, cherokee/win32_misc.h:
+ Add mkstemp() functionality missing in MinGW.
+
+2007-07-26 Alvaro Lopez Ortega <alvaro@alobbs.com>
+
* qa/run-tests.py: Added new option for showing how much memory is
the server using during the QA test execution.
@@ -502,7 +512,7 @@
* cherokee/win32_cservice.h, cherokee/win32_cservice.c,
cherokee/win32_cherokeeserv.c, windows/cherokee.reg: Added a Win32
- service. Code by Ross Smith II <cherokeespam@netebb.com>
+ service. Code by Ross Smith II <cherokeespam at netebb.com>
* cherokee/Makefile.am (win32_cherokeeserv), windows/cherokee.reg:
Created new binary target, and added win32_cservice.h,
@@ -513,7 +523,7 @@
* cherokee/win32_misc.h, cherokee/win32_misc.c: Added new func
cherokee_win32_shutdown_signaled(). Patch by Ross Smith II
- <cherokee@smithii.com>
+ <cherokeespam at netebb.com>
* cherokee/server.c (cherokee_server_step): Call
cherokee_win32_shutdown_signaled() before checking if the server
View
8 cherokee/post.c
@@ -84,6 +84,8 @@ cherokee_post_mrproper (cherokee_post_t *post)
ret_t
cherokee_post_set_len (cherokee_post_t *post, off_t len)
{
+ ret_t ret;
+
post->type = (len > POST_SIZE_TO_DISK) ? post_in_tmp_file : post_in_memory;
post->size = len;
@@ -92,10 +94,8 @@ cherokee_post_set_len (cherokee_post_t *post, off_t len)
/* Generate a unique name
*/
- post->tmp_file_fd = mkstemp (post->tmp_file.buf);
- if (unlikely (post->tmp_file_fd < 0)) {
- return ret_error;
- }
+ ret = cherokee_mkstemp (&post->tmp_file, &post->tmp_file_fd);
+ if (unlikely (ret != ret_ok)) return ret;
}
return ret_ok;
View
16 cherokee/util.c
@@ -1364,3 +1364,19 @@ cherokee_print_errno (int error, char *format, ...)
cherokee_buffer_mrproper (&buffer);
}
+
+ret_t
+cherokee_mkstemp (cherokee_buffer_t *buffer, int *fd)
+{
+ int re;
+
+#ifdef _WIN32
+ re = cherokee_win32_mkstemp (buffer);
+#else
+ re = mkstemp (buffer->buf);
+#endif
+ if (re < 0) return ret_error;
+
+ *fd = re;
+ return ret_ok;
+}
View
1  cherokee/util.h
@@ -98,6 +98,7 @@ ret_t cherokee_gethostbyname (const char *hostname, void *addr);
ret_t cherokee_syslog (int priority, cherokee_buffer_t *buf);
ret_t cherokee_getpwnam (const char *name, struct passwd *pwbuf, char *buf, size_t buflen);
ret_t cherokee_getgrnam (const char *name, struct group *pwbuf, char *buf, size_t buflen);
+ret_t cherokee_mkstemp (cherokee_buffer_t *buffer, int *fd);
/* Misc
*/
View
47 cherokee/win32_misc.c
@@ -48,6 +48,10 @@
/* __declspec(dllexport) */ const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
#endif
+#ifndef O_LARGEFILE
+# define O_LARGEFILE 0
+#endif
+
#define _ctor
#define EXIT_EVENT_NAME "cherokee_exit_1"
#define CLEAR(x) memset(&(x), 0, sizeof(x))
@@ -1060,3 +1064,46 @@ cherokee_win32_shutdown_signaled()
return WaitForSingleObject (exit_event, (DWORD) 0) == WAIT_OBJECT_0;
}
+
+int
+cherokee_win32_mkstemp (cherokee_buffer_t *buffer)
+{
+ int fd = -1;
+ static char tmp_file[MAX_PATH + 14] = {0};
+
+ while (1) {
+ char buferr[ERROR_MAX_BUFSIZE];
+
+ static char tmp_path[MAX_PATH + 14] = {0};
+ static UINT uUnique = 0;
+
+ *tmp_file = '\0';
+
+ if (!*tmp_path) {
+ if (!GetTempPath (sizeof(tmp_path), tmp_path)) {
+ cherokee_strerror_r (GetLastError (), buferr, sizeof(buferr));
+ PRINT_MSG ("Couldn't get temporary path: %s", buferr);
+ /* strcpy (tmp_path, "\\"); /* TODO FIXME use c:\Progra~\cherokee\var\tmp ? */
+ break;
+ }
+ }
+
+ if (!GetTempFileName (tmp_path, "chp", uUnique++, tmp_file)) {
+ cherokee_strerror_r (GetLastError(), buferr, sizeof(buferr));
+ PRINT_MSG ("Couldn't generate temporary file name: %s", buferr);
+ break;
+ }
+
+ fd = open (tmp_file, O_APPEND | O_WRONLY | O_CREAT | O_LARGEFILE | O_BINARY, 0600);
+ if (fd == -1) {
+ PRINT_MSG ("Couldn't create '%s': %s", tmp_file, strerror(errno));
+ break;
+ }
+
+ break;
+ }
+
+ cherokee_buffer_add_str (buffer, tmp_file);
+
+ return fd;
+}
View
6 cherokee/win32_misc.h
@@ -26,9 +26,12 @@
#ifndef CHEROKEE_WIN32_MISC_H
#define CHEROKEE_WIN32_MISC_H
+#include "common-internal.h"
+
#include <fcntl.h>
#include <winsock2.h>
-#include "common-internal.h"
+
+#include "buffer.h"
#undef localtime_r /* in <pthread.h> */
@@ -42,5 +45,6 @@ unsigned int sleep (unsigned int seconds);
int cherokee_win32_stat (const char *path, struct stat *buf);
int cherokee_win32_shutdown_signaled();
+int cherokee_win32_mkstemp (cherokee_buffer_t *buffer);
#endif /* CHEROKEE_WIN32_MISC_H */
Please sign in to comment.
Something went wrong with that request. Please try again.