35 if (attached !=
"true")
45 return owner->hasInlineBlobs;
51 auto xmlContent =
owner->xmlContent;
53 std::vector<int> sharedBuffers =
owner->sharedBuffers;
55 std::unordered_map<XMLEle*, XMLEle*> replacement;
64 if (attached !=
"true")
72 replacement[blobContent] = clone;
81 log(
"Missing size value for blob");
88 log(
fmt(
"Unable to allocate shared buffer of size %d : %s\n", size, strerror(
errno)));
91 log(
fmt(
"Blob allocated at %p\n", blob));
95 if (actualLen != size)
98 log(
fmt(
"Blob size mismatch after base64dec: %lld vs %lld\n", (
long long int)actualLen, (
long long int)size));
102 ownSharedBuffers.insert(newFd);
106 sharedBuffers.insert(sharedBuffers.begin() + blobPos, newFd);
111 if (!replacement.empty())
120 chunck.content = (
char*)malloc(
sprlXMLEle(xmlContent, 0) + 1);
122 chunck.contentLength =
sprXMLEle(chunck.content, xmlContent, 0);
123 chunck.sharedBufferIdsToAttach = sharedBuffers;
127 if (!replacement.empty())
140 for(
auto id : ownSharedBuffers)
void log(const std::string &log)
XMLEle * cloneXMLEleWithReplacementMap(XMLEle *root, const std::unordered_map< XMLEle *, XMLEle * > &replacement)
bool parseBlobSize(XMLEle *blobWithAttachedBuffer, ssize_t &size)
std::string fmt(const char *fmt,...)
std::vector< XMLEle * > findBlobElements(XMLEle *root)
int from64tobits_fast(char *out, const char *in, int inlen)
virtual ~SerializedMsgWithSharedBuffer()
SerializedMsgWithSharedBuffer(Msg *parent)
virtual bool generateContentAsync() const
virtual void generateContent()
std::list< void * > ownBuffers
void async_pushChunck(const MsgChunck &m)
const char * findXMLAttValu(XMLEle *ep, const char *name)
Find an XML element's attribute value.
size_t sprXMLEle(char *s, XMLEle *ep, int level)
sample print ep to string s. N.B. s must be at least as large as that reported by sprlXMLEle()+1....
void rmXMLAtt(XMLEle *ep, const char *name)
Remove an XML attribute from an XML element.
size_t sprlXMLEle(XMLEle *ep, int level)
return number of bytes in a string guaranteed able to hold result of sprXLMEle(ep) (sans trailing \0@...
void delXMLEle(XMLEle *ep)
delXMLEle Delete XML element.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.
XMLEle * shallowCloneXMLEle(XMLEle *ele)
return a surface copy of a node. Don't copy childs or cdata.
XMLAtt * addXMLAtt(XMLEle *ep, const char *name, const char *valu)
Add an XML attribute to an existing XML element.
int pcdatalenXMLEle(XMLEle *ep)
Return the number of characters in pcdata in an XML element.
void * IDSharedBlobAlloc(size_t size)
Allocate a buffer suitable for fast exchange over local links. Warning : the buffer will be sealed (r...
void IDSharedBlobDettach(void *ptr)
Dettach a blob, but don't close its FD.
int IDSharedBlobGetFd(void *ptr)
Return the filedescriptor backing up the given shared buffer.