iod_wk.c revision 613a2f6ba31e891e3d947a356daf5e563d43c1ce
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Functions called by the IO deamon (IOD).
* Here in the library to simplify testing.
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <libintl.h>
#include <sys/byteorder.h>
#include "charsets.h"
#include "private.h"
/*
* Be the reader thread for this VC.
*/
int
{
/* Calle should have opened these */
goto out;
}
/*
* This is the reader / reconnect loop.
*
* We could start with state "idle", but
* we know someone wants a connection to
* this server, so start in "vcactive".
*
* XXX: Add some syslog calls in here?
*/
for (;;) {
switch (vcst) {
case SMBIOD_ST_IDLE:
/*
* Wait for driver requests to arrive
* for this VC, then return here.
* Next state is normally RECONNECT.
*/
DPRINT("state: idle");
goto out;
}
continue;
case SMBIOD_ST_RECONNECT:
DPRINT("state: reconnect");
if (err == 0) {
continue;
}
/*
* If the error was EAUTH, retry is
* not likely to succeed either, so
* just exit this thread. The user
* will need to run smbutil to get
* a new thread with new auth info.
*/
goto out;
continue;
case SMBIOD_ST_RCFAILED:
DPRINT("state: rcfailed");
/*
* Reconnect failed. Kill off any
* requests waiting in the driver,
* then get ready to try again.
* Next state is normally IDLE.
*/
goto out;
}
continue;
case SMBIOD_ST_VCACTIVE:
DPRINT("state: active");
goto out;
}
continue;
case SMBIOD_ST_DEAD:
DPRINT("state: dead");
err = 0;
goto out;
default:
goto out;
}
}
out:
}
}
return (err);
}