We only use it in autofp mode, for reference counting purposes.
Removes 2 atomic operations per packet in the more common workers
runmode.
if (active_runmode == NULL || strcmp("workers", active_runmode) != 0) {
/* If we are using copy mode we need a lock */
aconf->flags |= AFP_SOCK_PROTECT;
+ aconf->flags |= AFP_NEED_PEER;
}
return aconf;
}
p->ReleasePacket = AFPReleasePacket;
p->afp_v.relptr = h.raw;
- p->afp_v.mpeer = ptv->mpeer;
- AFPRefSocket(ptv->mpeer);
+ if (ptv->flags & AFP_NEED_PEER) {
+ p->afp_v.mpeer = ptv->mpeer;
+ AFPRefSocket(ptv->mpeer);
+ } else {
+ p->afp_v.mpeer = NULL;
+ }
p->afp_v.copy_mode = ptv->copy_mode;
p->afp_v.peer = (p->afp_v.copy_mode == AFP_COPY_MODE_NONE) ? NULL : ptv->mpeer->peer;
#endif
/* value for flags */
-// (1<<0) vacant
+#define AFP_NEED_PEER (1 << 0)
// (1<<1) vacant
#define AFP_SOCK_PROTECT (1<<2)
#define AFP_EMERGENCY_MODE (1<<3)