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;
|
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
|
* 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))
|
if (ncp_conn_access(ncp, ncp->ucred, NCPM_WRITE))
|
||||||
return EACCES;
|
return EACCES;
|
||||||
|
|
||||||
if ((ncp->flags & (NCPFL_INVALID | NCPFL_ATTACHED)) == NCPFL_ATTACHED)
|
if (ncp->flags & NCPFL_ATTACHED)
|
||||||
ncp_ncp_disconnect(ncp);
|
ncp_ncp_disconnect(ncp);
|
||||||
ncp_sock_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);
|
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);
|
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);
|
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_ref(struct ncp_conn *conn, pid_t pid);
|
||||||
int ncp_conn_rm_ref(struct ncp_conn *conn, pid_t pid, int force);
|
int ncp_conn_rm_ref(struct ncp_conn *conn, pid_t pid, int force);
|
||||||
void ncp_conn_list_rm_ref(pid_t pid);*/
|
void ncp_conn_list_rm_ref(pid_t pid);*/
|
||||||
|
@ -103,8 +103,8 @@ ncp_ncp_connect(struct ncp_conn *conn)
|
|||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
conn->flags &= ~(NCPFL_INVALID | NCPFL_SIGNACTIVE | NCPFL_SIGNWANTED
|
conn->flags &= ~(NCPFL_SIGNACTIVE | NCPFL_SIGNWANTED |
|
||||||
| NCPFL_ATTACHED);
|
NCPFL_ATTACHED | NCPFL_LOGGED | NCPFL_INVALID);
|
||||||
conn->seq = 0;
|
conn->seq = 0;
|
||||||
error = ncp_request_int(rqp);
|
error = ncp_request_int(rqp);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -135,7 +135,7 @@ ncp_ncp_disconnect(struct ncp_conn *conn)
|
|||||||
ncp_rq_done(rqp);
|
ncp_rq_done(rqp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn->flags |= NCPFL_INVALID;
|
ncp_conn_invalidate(conn);
|
||||||
ncp_sock_disconnect(conn);
|
ncp_sock_disconnect(conn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -251,11 +251,9 @@ ncp_request_int(struct ncp_rq *rqp)
|
|||||||
struct mbchain *mbp;
|
struct mbchain *mbp;
|
||||||
int error, len, dosend, plen = 0, gotpacket;
|
int error, len, dosend, plen = 0, gotpacket;
|
||||||
|
|
||||||
if (conn->flags & NCPFL_INVALID)
|
|
||||||
return ENOTCONN;
|
|
||||||
if (so == NULL) {
|
if (so == NULL) {
|
||||||
printf("%s: ncp_so is NULL !\n",__FUNCTION__);
|
printf("%s: ncp_so is NULL !\n",__FUNCTION__);
|
||||||
conn->flags |= NCPFL_INVALID;
|
ncp_conn_invalidate(conn);
|
||||||
return ENOTCONN;
|
return ENOTCONN;
|
||||||
}
|
}
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
@ -386,7 +384,7 @@ ncp_request_int(struct ncp_rq *rqp)
|
|||||||
* connection now.
|
* connection now.
|
||||||
*/
|
*/
|
||||||
if (error != EINTR)
|
if (error != EINTR)
|
||||||
conn->flags |= NCPFL_INVALID;
|
ncp_conn_invalidate(conn);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
if (conn->flags & NCPFL_SIGNACTIVE) {
|
if (conn->flags & NCPFL_SIGNACTIVE) {
|
||||||
@ -403,7 +401,7 @@ ncp_request_int(struct ncp_rq *rqp)
|
|||||||
rqp->nr_cs = rp->connection_state;
|
rqp->nr_cs = rp->connection_state;
|
||||||
if (rqp->nr_cs & (NCP_CS_BAD_CONN | NCP_CS_SERVER_DOWN)) {
|
if (rqp->nr_cs & (NCP_CS_BAD_CONN | NCP_CS_SERVER_DOWN)) {
|
||||||
NCPSDEBUG("server drop us\n");
|
NCPSDEBUG("server drop us\n");
|
||||||
conn->flags |= NCPFL_INVALID;
|
ncp_conn_invalidate(conn);
|
||||||
error = ECONNRESET;
|
error = ECONNRESET;
|
||||||
}
|
}
|
||||||
md_get_mem(&rqp->rp, NULL, sizeof(*rp), MB_MSYSTEM);
|
md_get_mem(&rqp->rp, NULL, sizeof(*rp), MB_MSYSTEM);
|
||||||
@ -420,13 +418,12 @@ ncp_restore_login(struct ncp_conn *conn)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
printf("ncprq: Restoring connection, flags = %x\n", conn->flags);
|
printf("ncprq: Restoring connection, flags = %x\n", conn->flags);
|
||||||
conn->flags &= ~(NCPFL_LOGGED | NCPFL_ATTACHED);
|
|
||||||
conn->flags |= NCPFL_RESTORING;
|
conn->flags |= NCPFL_RESTORING;
|
||||||
error = ncp_conn_reconnect(conn);
|
error = ncp_conn_reconnect(conn);
|
||||||
if (!error && (conn->flags & NCPFL_WASLOGGED))
|
if (!error && (conn->flags & NCPFL_WASLOGGED))
|
||||||
error = ncp_login_object(conn, conn->li.user, conn->li.objtype, conn->li.password,conn->procp,conn->ucred);
|
error = ncp_login_object(conn, conn->li.user, conn->li.objtype, conn->li.password,conn->procp,conn->ucred);
|
||||||
if (error)
|
if (error)
|
||||||
conn->flags |= NCPFL_INVALID;
|
ncp_ncp_disconnect(conn);
|
||||||
conn->flags &= ~NCPFL_RESTORING;
|
conn->flags &= ~NCPFL_RESTORING;
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -442,9 +439,9 @@ ncp_request(struct ncp_rq *rqp)
|
|||||||
goto out;
|
goto out;
|
||||||
rcnt = NCP_RESTORE_COUNT;
|
rcnt = NCP_RESTORE_COUNT;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if ((ncp->flags & NCPFL_INVALID) == 0) {
|
if (ncp->flags & NCPFL_ATTACHED) {
|
||||||
error = ncp_request_int(rqp);
|
error = ncp_request_int(rqp);
|
||||||
if ((ncp->flags & NCPFL_INVALID) == 0)
|
if (ncp->flags & NCPFL_ATTACHED)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rcnt-- == 0) {
|
if (rcnt-- == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user