奇怪的session混乱问题

本文探讨了在JBoss4.2环境下遇到的一个奇怪现象:不同机器上的两个账号偶尔会互相获取到对方的session值。通过分析代码,提供了一段具体的业务逻辑实现,旨在寻找可能的原因及解决方案。
服务器:jboss4.2
问题:偶尔两个帐号在两台不同的机器上,a帐户获取了b帐号的session值
[code]public ActionForward loadDialogList4Inbox(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception{
MailService service = (MailService)this.getBean("mailService");
List labels = (List)request.getSession().getAttribute("labels");
if(labels == null){
labels = service.loadLabelWithTotal(this.getUserId());
request.getSession().setAttribute("labels",labels);
}
return mapping.findForward("dialogList");
}[/code]
static int relay_new_proc(Relay *self, bool re_only, uint32_t op) { int rfd[2] = {-1, -1}; int wfd[2] = {-1, -1}; pid_t pid; if (pipe(rfd) < 0) { SYS_ERROR("pipe"); rfd[0] = -1; rfd[1] = -1; goto error; } if (pipe(wfd) < 0) { SYS_ERROR("pipe"); wfd[0] = -1; wfd[1] = -1; goto error; } pid = fork(); if (pid < 0) { SYS_ERROR("fork"); goto error; } if (0 == pid) { /* Child. */ void tmpd_cleanup(void) { dm_destroy(); } CMM_RET cRet; cRet = dm_shmInit(0); if (cRet != CMM_OK) { ERROR("shm init failed."); exit(-1); } atexit(tmpd_cleanup); close(rfd[0]); rfd[0] = -1; close(wfd[1]); wfd[1] = -1; APP_SESSION appSession; int readnum = 0; memset(&appSession, 0, sizeof(appSession)); appSession.pRecvPkt = (char *)malloc(TMP_PACKET_MAX_PAYLOAD_SIZE + 1); appSession.pSendPkt = (char *)malloc(TMP_PACKET_MAX_PAYLOAD_SIZE + 1); if (op == 0x0003) { readnum = 0; } else { readnum = read(wfd[0], appSession.pRecvPkt, TMP_PACKET_MAX_PAYLOAD_SIZE); if (-1 != readnum) { appSession.pRecvPkt[readnum] = '\0'; } } INFO("readnum=[%d], buf = [%s]", readnum, appSession.pRecvPkt); rdp_handle(&appSession, op, readnum); ustream_fd_init(&self->rus, rfd[1]); ustream_write(&self->rus.stream, appSession.pSendPkt, appSession.nSendLen , false); free(appSession.pRecvPkt); free(appSession.pSendPkt); close(rfd[0]); close(rfd[1]); close(wfd[0]); close(wfd[1]); exit(1); } /* Parent. */ close(rfd[1]); rfd[1] = -1; close(wfd[0]); wfd[0] = -1; self->proc.pid = pid; if (uloop_process_add(&self->proc) < 0) { ERROR("uloop_process_add"); return -1; } ustream_fd_init(&self->rus, rfd[0]); ustream_fd_init(&self->wus, wfd[1]); /* Just in case. */ ustream_set_read_blocked(&self->wus.stream, true); INFO("Relay launched a new CGI process %d", pid); return 0; error: if (rfd[0] != -1) { close(rfd[0]); } if (rfd[1] != -1) { close(rfd[1]); } if (wfd[0] != -1) { close(wfd[0]); } if (wfd[1] != -1) { close(wfd[1]); } return -1; }这段什么意思
最新发布
11-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值