SAM_DATA_STORE(3)

πŸ’Ύ SAM_DATA_STORE(3) πŸ’Ύ

okay bestie, welcome to the Corosync Cluster Engine Programmer's Manual ✨ this is the page for sam_data_store(3), and we're gonna make it make sense, fr fr 🫢


🌸 NAME 🌸

sam_data_store β€” store user data πŸ’… (yes that's it, that's the whole name section, she's concise)


✨ SYNOPSIS ✨

#include <corosync/sam.h>

cs_error_t sam_data_store (const void *data, size_t size);

πŸŽ€ DESCRIPTION πŸŽ€

so the sam_data_store function is the one you call when you wanna store data, and the whole point is that this data survives between instances πŸ‘‘ like it outlives the current you, iconic behavior honestly.

the data parameter is a pointer to the memory holding the data you wanna store. and here's the cute part: the data gets stored in newly allocated memory inside the library, so the caller can safely delete their own copy right after the function call returns 🧚 no strings attached, no lingering references, we love a clean break.

you can also pass NULL as the parameter to remove and free whatever data was saved before. and in that case? the size argument is just ignored bestie, she said "not today" πŸ™ˆ

the size parameter is the length of the data. that's it, that's the whole job.

wanna know how big your stored data is? use sam_data_getsize(3) πŸ’– wanna get it back? use sam_data_restore(3) πŸ¦‹

🌈 RETURN VALUE 🌈

this call returns CS_OK if everything slayed, otherwise an error comes back at you. no cap 😭


πŸ’€ ERRORS πŸ’€

  • CS_ERR_BAD_HANDLE β€” the component was never initialized by calling sam_initialize(3), or it already got finalized. like, you showed up to the party with no invite, or you showed up after everyone left πŸ’€
  • CS_ERR_NO_MEMORY β€” internal malloc/realloc failed because the data is too large. she simply could not hold all that 😭
  • CS_ERR_LIBRARY β€” some internal error showed up, mostly because communication with the parent process failed. it's giving "it's not you, it's the parent process" πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

and also, since we're being thorough (we always are πŸ’…), here are the general error codes that can pop up too:

  • CS_ERR_TRY_AGAIN β€” Resource temporarily unavailable
  • CS_ERR_INVALID_PARAM β€” Invalid argument
  • CS_ERR_ACCESS β€” Permission denied
  • CS_ERR_LIBRARY β€” The connection failed
  • CS_ERR_INTERRUPT β€” System call interrupted by a signal
  • CS_ERR_NOT_SUPPORTED β€” The requested protocol/functionality not supported
  • CS_ERR_MESSAGE_ERROR β€” Incorrect auth message received
  • CS_ERR_NO_MEMORY β€” Not enough memory to complete the requested task

and that's the whole page, bestie!! this little cutie came from the corosync Man Page, dated 04/15/2010 🌸 go forth and store your data, you absolute main character πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from