Properly set flags on the broken connection.
This commit is contained in:
parent
d9d1a7bb94
commit
60457bde5a
@ -195,6 +195,18 @@ ncp_conn_assert_locked(struct ncp_conn *conn,char *checker, struct proc *p){
|
||||
return EIO;
|
||||
}
|
||||
|
||||
void
|
||||
ncp_conn_invalidate(struct ncp_conn *ncp)
|
||||
{
|
||||
ncp->flags &= ~(NCPFL_ATTACHED | NCPFL_LOGGED | NCPFL_INVALID);
|
||||
}
|
||||
|
||||
int
|
||||
ncp_conn_invalid(struct ncp_conn *ncp)
|
||||
{
|
||||
return ncp->flags & NCPFL_INVALID;
|
||||
}
|
||||
|
||||
/*
|
||||
* create, fill with defaults and return in locked state
|
||||
*/
|
||||
@ -275,7 +287,7 @@ ncp_conn_free(struct ncp_conn *ncp)
|
||||
if (ncp_conn_access(ncp, ncp->ucred, NCPM_WRITE))
|
||||
return EACCES;
|
||||
|
||||
if ((ncp->flags & (NCPFL_INVALID | NCPFL_ATTACHED)) == NCPFL_ATTACHED)
|
||||
if (ncp->flags & NCPFL_ATTACHED)
|
||||
ncp_ncp_disconnect(ncp);
|
||||
ncp_sock_disconnect(ncp);
|
||||
|
||||
|
@ -201,6 +201,8 @@ int ncp_conn_access(struct ncp_conn *conn,struct ucred *cred,mode_t mode);
|
||||
int ncp_conn_lock(struct ncp_conn *conn,struct proc *p,struct ucred *cred,int mode);
|
||||
void ncp_conn_unlock(struct ncp_conn *conn,struct proc *p);
|
||||
int ncp_conn_assert_locked(struct ncp_conn *conn,char *checker,struct proc *p);
|
||||
void ncp_conn_invalidate(struct ncp_conn *ncp);
|
||||
int ncp_conn_invalid(struct ncp_conn *ncp);
|
||||
/*int ncp_conn_ref(struct ncp_conn *conn, pid_t pid);
|
||||
int ncp_conn_rm_ref(struct ncp_conn *conn, pid_t pid, int force);
|
||||
void ncp_conn_list_rm_ref(pid_t pid);*/
|
||||
|
@ -103,8 +103,8 @@ ncp_ncp_connect(struct ncp_conn *conn)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
conn->flags &= ~(NCPFL_INVALID | NCPFL_SIGNACTIVE | NCPFL_SIGNWANTED
|
||||
| NCPFL_ATTACHED);
|
||||
conn->flags &= ~(NCPFL_SIGNACTIVE | NCPFL_SIGNWANTED |
|
||||
NCPFL_ATTACHED | NCPFL_LOGGED | NCPFL_INVALID);
|
||||
conn->seq = 0;
|
||||
error = ncp_request_int(rqp);
|
||||
if (!error) {
|
||||
@ -135,7 +135,7 @@ ncp_ncp_disconnect(struct ncp_conn *conn)
|
||||
ncp_rq_done(rqp);
|
||||
}
|
||||
}
|
||||
conn->flags |= NCPFL_INVALID;
|
||||
ncp_conn_invalidate(conn);
|
||||
ncp_sock_disconnect(conn);
|
||||
return 0;
|
||||
}
|
||||
|
@ -251,11 +251,9 @@ ncp_request_int(struct ncp_rq *rqp)
|
||||
struct mbchain *mbp;
|
||||
int error, len, dosend, plen = 0, gotpacket;
|
||||
|
||||
if (conn->flags & NCPFL_INVALID)
|
||||
return ENOTCONN;
|
||||
if (so == NULL) {
|
||||
printf("%s: ncp_so is NULL !\n",__FUNCTION__);
|
||||
conn->flags |= NCPFL_INVALID;
|
||||
ncp_conn_invalidate(conn);
|
||||
return ENOTCONN;
|
||||
}
|
||||
if (p == NULL)
|
||||
@ -386,7 +384,7 @@ ncp_request_int(struct ncp_rq *rqp)
|
||||
* connection now.
|
||||
*/
|
||||
if (error != EINTR)
|
||||
conn->flags |= NCPFL_INVALID;
|
||||
ncp_conn_invalidate(conn);
|
||||
return (error);
|
||||
}
|
||||
if (conn->flags & NCPFL_SIGNACTIVE) {
|
||||
@ -403,7 +401,7 @@ ncp_request_int(struct ncp_rq *rqp)
|
||||
rqp->nr_cs = rp->connection_state;
|
||||
if (rqp->nr_cs & (NCP_CS_BAD_CONN | NCP_CS_SERVER_DOWN)) {
|
||||
NCPSDEBUG("server drop us\n");
|
||||
conn->flags |= NCPFL_INVALID;
|
||||
ncp_conn_invalidate(conn);
|
||||
error = ECONNRESET;
|
||||
}
|
||||
md_get_mem(&rqp->rp, NULL, sizeof(*rp), MB_MSYSTEM);
|
||||
@ -420,13 +418,12 @@ ncp_restore_login(struct ncp_conn *conn)
|
||||
int error;
|
||||
|
||||
printf("ncprq: Restoring connection, flags = %x\n", conn->flags);
|
||||
conn->flags &= ~(NCPFL_LOGGED | NCPFL_ATTACHED);
|
||||
conn->flags |= NCPFL_RESTORING;
|
||||
error = ncp_conn_reconnect(conn);
|
||||
if (!error && (conn->flags & NCPFL_WASLOGGED))
|
||||
error = ncp_login_object(conn, conn->li.user, conn->li.objtype, conn->li.password,conn->procp,conn->ucred);
|
||||
if (error)
|
||||
conn->flags |= NCPFL_INVALID;
|
||||
ncp_ncp_disconnect(conn);
|
||||
conn->flags &= ~NCPFL_RESTORING;
|
||||
return error;
|
||||
}
|
||||
@ -442,9 +439,9 @@ ncp_request(struct ncp_rq *rqp)
|
||||
goto out;
|
||||
rcnt = NCP_RESTORE_COUNT;
|
||||
for(;;) {
|
||||
if ((ncp->flags & NCPFL_INVALID) == 0) {
|
||||
if (ncp->flags & NCPFL_ATTACHED) {
|
||||
error = ncp_request_int(rqp);
|
||||
if ((ncp->flags & NCPFL_INVALID) == 0)
|
||||
if (ncp->flags & NCPFL_ATTACHED)
|
||||
break;
|
||||
}
|
||||
if (rcnt-- == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user