about summary refs log tree commit homepage
path: root/http_put.c
diff options
context:
space:
mode:
Diffstat (limited to 'http_put.c')
-rw-r--r--http_put.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/http_put.c b/http_put.c
index 9974c93..103c2c1 100644
--- a/http_put.c
+++ b/http_put.c
@@ -320,13 +320,15 @@ static char *tmppath_for(struct mog_http *http, const char *path)
 static struct mog_file * open_put(struct mog_http *http, char *path)
 {
         struct mog_file *file;
+        struct mog_svc *svc = http->svc;
+        uint32_t devid = http->_p.mog_devid;
 
         /*
          * we can't do an atomic rename(2) on successful PUT
          * if we have a partial upload
          */
         if (http->_p.has_content_range) {
-                http->forward = mog_file_open_put(http->svc, path, O_CREAT);
+                http->forward = mog_file_open_put(svc, devid, path, O_CREAT);
                 if (http->forward == NULL)
                         return NULL;
 
@@ -337,13 +339,13 @@ static struct mog_file * open_put(struct mog_http *http, char *path)
                 char *tmp = tmppath_for(http, path);
                 int fl = O_EXCL | O_TRUNC | O_CREAT;
 
-                http->forward = mog_file_open_put(http->svc, tmp, fl);
+                http->forward = mog_file_open_put(svc, devid, tmp, fl);
 
                 /* retry once on EEXIST, don't inf loop if RNG is broken */
                 if (http->forward == NULL && errno == EEXIST) {
                         free(tmp);
                         tmp = tmppath_for(http, path);
-                        http->forward = mog_file_open_put(http->svc, tmp, fl);
+                        http->forward = mog_file_open_put(svc, devid, tmp, fl);
                 }
                 if (http->forward == NULL) {
                         PRESERVE_ERRNO( free(tmp) );
@@ -507,7 +509,9 @@ retry:
         }
         if (r != 0) {
                 switch (errno) {
-                case_EAGAIN: return MOG_NEXT_WAIT_RD;
+                case_EAGAIN:
+                        mog_file_post(http->forward);
+                        return MOG_NEXT_WAIT_RD;
                 case EINTR: goto retry;
                 }
         }
@@ -630,7 +634,9 @@ chunk_state_trailer:
 read_err:
         if (r < 0) {
                 switch (errno) {
-                case_EAGAIN: return MOG_NEXT_WAIT_RD;
+                case_EAGAIN:
+                        mog_file_post(http->forward);
+                        return MOG_NEXT_WAIT_RD;
                 }
         }
         read_err_dbg(mfd, r);
@@ -639,6 +645,8 @@ read_err:
 
 enum mog_next mog_http_put_in_progress(struct mog_fd *mfd)
 {
+        mog_file_ensure_wait(mfd->as.http.forward);
+
         if (mfd->as.http._p.chunked)
                 return chunked_put_in_progress(mfd);