Skip to content

Commit

Permalink
use endian.h for expires too
Browse files Browse the repository at this point in the history
  • Loading branch information
msotheeswaran-sc committed Oct 6, 2023
1 parent 1f976f8 commit 0449579
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/storage/rocksdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <sstream>
#include <mutex>
#include <unistd.h>
#include <arpa/inet.h>
#include "../server.h"
#include "../cluster.h"
#include "rocksdbfactor_internal.h"
Expand Down Expand Up @@ -231,7 +230,7 @@ void RocksDBStorageProvider::setExpire(const char *key, size_t cchKey, long long
{
rocksdb::Status status;
std::unique_lock<fastlock> l(m_lock);
long long beExpire = htonll(expire);
long long beExpire = htobe64(expire);
std::string prefix((const char *)&beExpire,sizeof(long long));
std::string strKey(key, cchKey);
if (m_spbatch != nullptr)
Expand All @@ -246,7 +245,7 @@ void RocksDBStorageProvider::removeExpire(const char *key, size_t cchKey, long l
{
rocksdb::Status status;
std::unique_lock<fastlock> l(m_lock);
long long beExpire = htonll(expire);
long long beExpire = htobe64(expire);
std::string prefix((const char *)&beExpire,sizeof(long long));
std::string strKey(key, cchKey);
std::string fullKey = prefix + strKey;
Expand Down
5 changes: 3 additions & 2 deletions src/storage/rocksdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#include <rocksdb/utilities/write_batch_with_index.h>
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define htole16(x) OSSwapHostToLittleInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define htole16 OSSwapHostToLittleInt16
#define le16toh OSSwapLittleToHostInt16
#define htobe64 OSSwapHostToBigInt64
#else
#include <endian.h>
#endif
Expand Down

0 comments on commit 0449579

Please sign in to comment.