Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
392d13cd
Kaydet (Commit)
392d13cd
authored
Nis 10, 2008
tarafından
Bahadır Kandemir
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
cancel() method for tr.org.pardus.comar interface, kill all jobs of caller.
Optional jobNO argument will be added soon
üst
6bb1a473
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
3 deletions
+54
-3
model.xml
comar/etc/model.xml
+3
-0
log.h
comar/include/log.h
+1
-0
process.h
comar/include/process.h
+1
-0
dbus.c
comar/src/dbus.c
+45
-1
process.c
comar/src/process.c
+4
-2
No files found.
comar/etc/model.xml
Dosyayı görüntüle @
392d13cd
...
...
@@ -29,6 +29,9 @@
<arg
name=
"application"
type=
"s"
direction=
"in"
/>
<arg
name=
"models"
type=
"as"
direction=
"out"
/>
</method>
<method
name=
"cancel"
>
<arg
name=
"killed_jobs"
type=
"i"
direction=
"out"
/>
</method>
</interface>
<interface
name=
"Boot.Loader"
>
<method
name=
"listSystems"
access_label=
"get"
>
...
...
comar/include/log.h
Dosyayı görüntüle @
392d13cd
...
...
@@ -11,6 +11,7 @@
#define LOG_PROC 2
#define LOG_PLCY 4
#define LOG_PERF 8
#define LOG_ARGS 16
#define LOG_FULL 0xffffffff
int
log_start
(
void
);
...
...
comar/include/process.h
Dosyayı görüntüle @
392d13cd
...
...
@@ -13,6 +13,7 @@ struct ProcChild {
int
from
;
int
to
;
pid_t
pid
;
DBusMessage
*
bus_msg
;
const
char
*
desc
;
};
...
...
comar/src/dbus.c
Dosyayı görüntüle @
392d13cd
...
...
@@ -488,7 +488,9 @@ dbus_app_methods(const char *interface, const char *path, const char *method)
}
else
{
args
=
PyList_AsTuple
(
dbus_py_import
(
my_proc
.
bus_msg
));
log_debug
(
LOG_ARGS
,
"Arguments: %s
\n
"
,
PyString_AsString
(
PyObject_Repr
(
args
)));
ret
=
py_call_method
(
app
,
model
,
method
,
args
,
&
result
);
log_debug
(
LOG_ARGS
,
"Reply: %s
\n
"
,
PyString_AsString
(
PyObject_Repr
(
result
)));
if
(
ret
==
1
)
{
log_error
(
"Unable to find: %s (%s)
\n
"
,
model
,
app
);
...
...
@@ -509,6 +511,30 @@ dbus_app_methods(const char *interface, const char *path, const char *method)
free
(
model
);
}
//! Cancels all running jobs of sender
static
void
dbus_cancel
()
{
int
i
,
count
=
0
;
log_debug
(
LOG_DBUS
,
"Cancel requested.
\n
"
);
for
(
i
=
0
;
i
<
my_proc
.
nr_children
;
i
++
)
{
if
(
dbus_message_has_sender
(
my_proc
.
children
[
i
].
bus_msg
,
dbus_message_get_sender
(
my_proc
.
bus_msg
)))
{
kill
(
my_proc
.
children
[
i
].
pid
,
SIGKILL
);
count
++
;
}
}
log_debug
(
LOG_PROC
,
"%d processes killed.
\n
"
,
count
);
if
(
dbus_message_get_no_reply
(
my_proc
.
bus_msg
))
return
;
DBusMessage
*
reply
;
DBusMessageIter
iter
;
reply
=
dbus_message_new_method_return
(
my_proc
.
bus_msg
);
dbus_message_iter_init_append
(
reply
,
&
iter
);
dbus_message_iter_append_basic
(
&
iter
,
DBUS_TYPE_INT32
,
&
count
);
dbus_send
(
reply
);
}
//! Checks if sender is allowed to call specified method
static
int
dbus_policy_check
(
const
char
*
sender
,
const
char
*
interface
,
const
char
*
method
)
...
...
@@ -617,12 +643,27 @@ filter_func(DBusConnection *conn, DBusMessage *msg, void *data)
{
const
char
*
sender
=
dbus_message_get_sender
(
msg
);
const
char
*
interface
=
dbus_message_get_interface
(
msg
);
const
char
*
path
=
dbus_message_get_path
(
msg
);
const
char
*
method
=
dbus_message_get_member
(
msg
);
switch
(
dbus_message_get_type
(
msg
))
{
case
DBUS_MESSAGE_TYPE_METHOD_CALL
:
log_debug
(
LOG_DBUS
,
"DBus method call [%s.%s] from [%s]
\n
"
,
interface
,
method
,
sender
);
proc_fork
(
dbus_method_call
,
"ComarJob"
,
conn
,
msg
);
// Attach message to process header
my_proc
.
bus_msg
=
msg
;
if
(
!
interface
||
!
path
||
!
method
)
{
dbus_reply_error
(
"dbus"
,
"missing"
,
"Missing interface, path or method."
);
}
else
if
(
strncmp
(
interface
,
cfg_bus_interface
,
strlen
(
cfg_bus_interface
))
==
0
&&
strcmp
(
path
,
"/"
)
==
0
&&
strcmp
(
interface
,
cfg_bus_interface
)
==
0
&&
strcmp
(
method
,
"cancel"
)
==
0
)
{
dbus_cancel
();
}
else
{
proc_fork
(
dbus_method_call
,
"ComarJob"
,
conn
,
msg
);
}
break
;
case
DBUS_MESSAGE_TYPE_SIGNAL
:
log_debug
(
LOG_DBUS
,
"DBus signal [%s.%s] from [%s]
\n
"
,
interface
,
method
,
sender
);
...
...
@@ -751,6 +792,9 @@ dbus_listen()
unique_name
=
dbus_bus_get_unique_name
(
conn
);
log_info
(
"Listening on %s (%s)...
\n
"
,
cfg_bus_name
,
unique_name
);
// Attach connection to process header
my_proc
.
bus_conn
=
conn
;
while
(
1
)
{
struct
pollfd
fds
[
MAX_FDS
];
DBusWatch
*
watch
[
MAX_WATCHES
];
...
...
comar/src/process.c
Dosyayı görüntüle @
392d13cd
...
...
@@ -131,7 +131,7 @@ proc_init(int argc, char *argv[], const char *name)
//! Appends child process' information to parent's info table
static
struct
ProcChild
*
add_child
(
pid_t
pid
,
int
to
,
int
from
,
const
char
*
desc
)
add_child
(
pid_t
pid
,
int
to
,
int
from
,
DBusMessage
*
bus_msg
,
const
char
*
desc
)
{
/*!
* Appends child process' information to parent's info table.
...
...
@@ -139,6 +139,7 @@ add_child(pid_t pid, int to, int from, const char *desc)
* @pid Process ID
* @to Input FD
* @from Output FD
* @bus_msg DBus message
* @desc Process description
* @return ProcChild node
*/
...
...
@@ -160,6 +161,7 @@ add_child(pid_t pid, int to, int from, const char *desc)
my_proc
.
children
[
i
].
from
=
from
;
my_proc
.
children
[
i
].
to
=
to
;
my_proc
.
children
[
i
].
pid
=
pid
;
my_proc
.
children
[
i
].
bus_msg
=
bus_msg
;
my_proc
.
children
[
i
].
desc
=
desc
;
++
my_proc
.
nr_children
;
return
&
my_proc
.
children
[
i
];
...
...
@@ -324,7 +326,7 @@ proc_fork(void (*child_func)(void), const char *desc, DBusConnection *bus_conn,
// parent process continues
close
(
fdw
[
0
]);
close
(
fdr
[
1
]);
return
add_child
(
pid
,
fdw
[
1
],
fdr
[
0
],
desc
);
return
add_child
(
pid
,
fdw
[
1
],
fdr
[
0
],
bus_msg
,
desc
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment