MXS-1262: Minor improvements to monitor journals
Moved 4 byte get/set into utils header. The byte packing functions in maxscale/protocol/mysql.h should be migrated to the utils directory where they can also be used by non-mysql code. The temporary files are now generated with mkstemp. This will prevent conflicts with multiple monitors operating on the same temporary journal even though it is impossible in practice. Added missing error messages to a couple of the functions.
This commit is contained in:
@ -123,4 +123,35 @@ bool mxs_mkdir_all(const char *path, int mask);
|
||||
|
||||
long get_processor_count();
|
||||
|
||||
/**
|
||||
* Store a 4 byte integer
|
||||
*
|
||||
* @param ptr Pointer where value is stored
|
||||
* @param value Value to store
|
||||
*
|
||||
* @return The next byte after the stored value
|
||||
*/
|
||||
static inline uint8_t* mxs_set_byte4(uint8_t* ptr, uint32_t value)
|
||||
{
|
||||
*ptr++ = value;
|
||||
*ptr++ = (value >> 8);
|
||||
*ptr++ = (value >> 16);
|
||||
*ptr++ = (value >> 24);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a 4 byte integer
|
||||
*
|
||||
* @param ptr Pointer where value is stored
|
||||
* @param value Value to store
|
||||
*
|
||||
* @return The next byte after the stored value
|
||||
*/
|
||||
static inline uint32_t mxs_get_byte4(const uint8_t* ptr)
|
||||
{
|
||||
return ((uint32_t) ptr[0]) | ((uint32_t) ptr[1] << 8) |
|
||||
((uint32_t) ptr[2] << 16) | ((uint32_t) ptr[3] << 24);
|
||||
}
|
||||
|
||||
MXS_END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user