kopia lustrzana https://gitlab.com/sane-project/backends
pixma_bjnp.c: Open TCP-connection only from bjnp_activate. bjnp_open should not intiate
a connection. This solves issues where the scanner closes it's TCP-connection after a period of no activity.merge-requests/1/head
rodzic
a3a2d2038d
commit
3ce1cec6a3
|
@ -2098,29 +2098,12 @@ extern SANE_Status
|
|||
sanei_bjnp_open (SANE_String_Const devname, SANE_Int * dn)
|
||||
{
|
||||
int result;
|
||||
char hostname[256];
|
||||
char pid_str[64];
|
||||
|
||||
|
||||
PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_open(%s, %d):\n", devname, *dn));
|
||||
|
||||
result = bjnp_allocate_device (devname, dn, NULL);
|
||||
if ( (result != BJNP_STATUS_GOOD) && (result != BJNP_STATUS_ALREADY_ALLOCATED ) )
|
||||
return SANE_STATUS_INVAL;
|
||||
|
||||
/* return sanei_bjnp_activate( *dn); */
|
||||
gethostname (hostname, 256);
|
||||
hostname[255] = '\0';
|
||||
sprintf (pid_str, "Process ID = %d", getpid ());
|
||||
|
||||
bjnp_send_job_details (*dn, hostname, getusername (), pid_str);
|
||||
|
||||
if (bjnp_open_tcp (*dn) != 0)
|
||||
{
|
||||
return SANE_STATUS_INVAL;
|
||||
}
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/** Close a BJNP device.
|
||||
|
@ -2132,14 +2115,9 @@ void
|
|||
sanei_bjnp_close (SANE_Int dn)
|
||||
{
|
||||
PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_close(%d):\n", dn));
|
||||
bjnp_finish_job (dn);
|
||||
|
||||
if ( device[dn].tcp_socket != -1)
|
||||
{
|
||||
close (device[dn].tcp_socket);
|
||||
device[dn].tcp_socket = -1;
|
||||
}
|
||||
device[dn].open = 0;
|
||||
sanei_bjnp_deactivate(dn);
|
||||
}
|
||||
|
||||
/** Activate BJNP device connection
|
||||
|
@ -2150,7 +2128,21 @@ sanei_bjnp_close (SANE_Int dn)
|
|||
SANE_Status
|
||||
sanei_bjnp_activate (SANE_Int dn)
|
||||
{
|
||||
char hostname[256];
|
||||
char pid_str[64];
|
||||
|
||||
PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_activate (%d)\n", dn));
|
||||
gethostname (hostname, 256);
|
||||
hostname[255] = '\0';
|
||||
sprintf (pid_str, "Process ID = %d", getpid ());
|
||||
|
||||
bjnp_send_job_details (dn, hostname, getusername (), pid_str);
|
||||
|
||||
if (bjnp_open_tcp (dn) != 0)
|
||||
{
|
||||
return SANE_STATUS_INVAL;
|
||||
}
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
@ -2163,6 +2155,12 @@ SANE_Status
|
|||
sanei_bjnp_deactivate (SANE_Int dn)
|
||||
{
|
||||
PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_deactivate (%d)\n", dn));
|
||||
if ( device[dn].tcp_socket != -1)
|
||||
{
|
||||
bjnp_finish_job (dn);
|
||||
close (device[dn].tcp_socket);
|
||||
device[dn].tcp_socket = -1;
|
||||
}
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue