diff options
| author | Unbit <info@unbit.it> | 2013-11-30 18:30:52 +0000 |
|---|---|---|
| committer | Unbit <info@unbit.it> | 2013-11-30 18:30:52 +0000 |
| commit | b934ac958825a0d610aee356396abdc6a3608fce (patch) | |
| tree | 95766ebcd434df094dd98dd1ea0d79cbc932dc2b /core/sharedarea.c | |
| parent | 92b6c62cac80ae1f812270736e5b579f392f8f7b (diff) | |
| download | uwsgi-b934ac958825a0d610aee356396abdc6a3608fce.tar.gz | |
refactored sharedarea read
Diffstat (limited to 'core/sharedarea.c')
| -rw-r--r-- | core/sharedarea.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/sharedarea.c b/core/sharedarea.c index 0a14a680..1593b739 100644 --- a/core/sharedarea.c +++ b/core/sharedarea.c @@ -26,16 +26,16 @@ struct uwsgi_sharedarea *uwsgi_sharedarea_get_by_id(int id, uint64_t pos) { return sa; } -int uwsgi_sharedarea_read(int id, uint64_t pos, char *blob, uint64_t len) { +int64_t uwsgi_sharedarea_read(int id, uint64_t pos, char *blob, uint64_t len) { struct uwsgi_sharedarea *sa = uwsgi_sharedarea_get_by_id(id, pos); if (!sa) return -1; if (pos + len > sa->max_pos + 1) return -1; - if (len == 0) len = (sa->max_pos + 1) - pos; + if (len == 0) len = sa->honour_used ? sa->used-pos : (sa->max_pos + 1) - pos; uwsgi_rlock(sa->lock); memcpy(blob, sa->area + pos, len); sa->hits++; uwsgi_rwunlock(sa->lock); - return 0; + return len; } int uwsgi_sharedarea_write(int id, uint64_t pos, char *blob, uint64_t len) { |
