diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2010-05-17 12:26:23 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2010-05-17 12:26:23 +0000 |
commit | 6e764a27dd76252281f10f0b6e88f2f6acea5c1a (patch) | |
tree | e62a9310d7a2651ef9add8d245d40a7b70911b29 /src/couchdb/priv | |
parent | b71f475d9d42ca2b8a30465cee615d633ce47d55 (diff) |
use O_APPEND to skip some lseeks, COUCHDB-754
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@945110 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/priv')
-rw-r--r-- | src/couchdb/priv/icu_driver/couch_icu_driver.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/couchdb/priv/icu_driver/couch_icu_driver.c b/src/couchdb/priv/icu_driver/couch_icu_driver.c index 1afe8eac..0bb843b5 100644 --- a/src/couchdb/priv/icu_driver/couch_icu_driver.c +++ b/src/couchdb/priv/icu_driver/couch_icu_driver.c @@ -27,8 +27,11 @@ specific language governing permissions and limitations under the License. #include "unicode/ucasemap.h" #ifndef WIN32 #include <string.h> // for memcpy +#include <fcntl.h> // for O_DSYNC #endif +#define SET_OSYNC_OPCODE 2 + typedef struct { ErlDrvPort port; UCollator* collNoCase; @@ -90,6 +93,19 @@ static int return_control_result(void* pLocalResult, int localLen, char **ppRetB return localLen; } +static char set_osync(int fd) { + int flags = fcntl(fd, F_GETFL, 0); + if (flags != -1) { + if (fcntl(fd, F_SETFL, flags | O_DSYNC) != -1) { + return 0; + } else { + return 1; + } + } else { + return 2; + } +} + static int couch_drv_control(ErlDrvData drv_data, unsigned int command, char *pBuf, int bufLen, char **rbuf, int rlen) { @@ -141,6 +157,14 @@ static int couch_drv_control(ErlDrvData drv_data, unsigned int command, char *pB return return_control_result(&response, sizeof(response), rbuf, rlen); } + case SET_OSYNC_OPCODE: // set O_SYNC flag on file descriptor + { + int32_t fd; + memcpy(&fd, pBuf, sizeof(fd)); + char response = set_osync(fd); + return return_control_result(&response, sizeof(response), rbuf, rlen); + } + default: return -1; } |